上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 36 下一页
摘要: Do not forget to assign size value of matrix. This is very important!!!! 1 class Solution { 2 public: 3 vector > generateMatrix(int n) { 4 ... 阅读全文
posted @ 2015-03-24 14:39 keepshuatishuati 阅读(115) 评论(0) 推荐(0) 编辑
摘要: When finally check the middle line, it is checking whether the min(n, m) is odd or even number. 1 class Solution { 2 public: 3 vector spiralOrder(... 阅读全文
posted @ 2015-03-24 14:34 keepshuatishuati 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Use merge sort. Recursively call the function: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNod... 阅读全文
posted @ 2015-03-24 14:24 keepshuatishuati 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 void sortColors(int A[], int n) { 4 auto swap = [](int &a, int &b){int t = a; a = b; b = t;}; 5 in... 阅读全文
posted @ 2015-03-23 15:11 keepshuatishuati 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int singleNumber(int A[], int n) { 4 int ones = 0, twos = 0, threes = 0; 5 for (int i = 0; i < n; ... 阅读全文
posted @ 2015-03-23 15:08 keepshuatishuati 阅读(135) 评论(0) 推荐(0) 编辑
摘要: You can use a hash map to record the frequencys. Or you can use bit operation.x ^ x = 0. So the only left is the one. 1 class Solution { 2 public: 3 ... 阅读全文
posted @ 2015-03-23 15:05 keepshuatishuati 阅读(78) 评论(0) 推荐(0) 编辑
摘要: I split it in the reverse way. So all the following code should do reverse way. 1 class Solution { 2 public: 3 vector splits(string s) { 4 ... 阅读全文
posted @ 2015-03-23 15:00 keepshuatishuati 阅读(115) 评论(0) 推荐(0) 编辑
摘要: You can use two array to record the zeros. Also you can do it in memory: 1 class Solution { 2 public: 3 void setZeroes(vector > &matrix) { 4 ... 阅读全文
posted @ 2015-03-23 13:50 keepshuatishuati 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Regular binary search 1 class Solution { 2 public: 3 int searchInsert(int A[], int n, int target) { 4 int start = 0, end = n-1, mid = 0; 5... 阅读全文
posted @ 2015-03-23 13:23 keepshuatishuati 阅读(87) 评论(0) 推荐(0) 编辑
摘要: Just skip the duplicated ones. 1 class Solution { 2 public: 3 bool search(int A[], int n, int target) { 4 int start = 0, end = n-1, mid = ... 阅读全文
posted @ 2015-03-23 13:13 keepshuatishuati 阅读(116) 评论(0) 推荐(0) 编辑
上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 36 下一页