- 博客(13)
- 资源 (3)
- 收藏
- 关注
原创 33. Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index
2016-07-26 19:21:28 175
原创 Max Sum of Rectangle No Larger Than K
对于一维数组求最大的和并且不大于K对于二维数组,转化为一维的迭代代码:class Solution {public: int maxSumSubmatrix(vector<vector<int>>& matrix, int k) { if (matrix.empty()) return 0; int row = matrix.si
2016-07-22 15:23:10 268
原创 50.Pow(x,n)
求x的幂次方Implement pow(x, n).二分法注意-n 转化为n的时候溢出,需要处理一下class Solution {//超时用不了public:double myPow(double x, int n) { if(n==0) return 1; double t = myPow(x,n/2); if(n%2) return n<0 ? 1/x*t*t
2016-07-22 09:57:51 227
原创 236. Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and
2016-07-18 22:00:41 195
原创 119. Pascal's Triangle II
Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3, Return [1,3,3,1].这就是杨辉三角class Solution {public: vector<int> getRow(int rowIndex) { vector<int> row(
2016-07-11 09:50:36 162
原创 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may no
2016-07-05 11:30:13 196
原创 1.Two Sum
1.Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example: Given nums =
2016-06-22 10:42:45 154
原创 337 leetcode House Robber III
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2016-06-22 09:50:21 223
原创 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, t
2016-04-07 11:11:09 177
原创 字符串以为包含问题
char src[] = "AABBCD"; char des[] = "CDAA";如上两个字符串,则输出true#include <stdio.h>#include <assert.h>#include <string.h>int main(){ char src[] = "AABBCD"; char des[] = "CDAA"; int len = strlen(src);
2016-03-31 19:17:48 185
原创 C语言字符串strlen函数使用
计算字符串长度 以及自己实现一个strlen的函数 用法 #include #include <stdio.h>#include <assert.h>#include <string.h>typedef unsigned int u_int;u_int Mystrlen(char *str);int main(){ char *s = "Melissa Yang"; printf(
2016-03-31 17:40:46 1077
原创 326. Power of Three LeetCode解题报告
Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 解法一:采用循环,O(lg(N))的速度class Solution {public: bool isPowe
2016-01-13 17:48:09 230
转载 欢迎使用CSDN-markdown编辑器
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2016-01-13 17:36:19 183
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人