摘要: class Solution { public: void SplitString(const string& s, vector& v, const string& c) { string::size_type pos1, pos2; pos2 = s.find(c); pos1 = 0; while (strin... 阅读全文
posted @ 2018-09-27 22:40 Sempron2800+ 阅读(108) 评论(0) 推荐(0) 编辑
摘要: vector shortestToChar(string S, char C) { vector V; const int N = 10001; int AYC[N]; int countC = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == C) { ... 阅读全文
posted @ 2018-09-27 22:14 Sempron2800+ 阅读(82) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector v1; vector v2; void GetLeaf(TreeNode* tree, int type) { if (tree->left != NULL || tree->right != NULL) { if (tree->left != ... 阅读全文
posted @ 2018-09-27 20:41 Sempron2800+ 阅读(82) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: TreeNode* searchBST(TreeNode* root, int val) { if (root == NULL) { return nullptr; } if (root->val == val) { ... 阅读全文
posted @ 2018-09-27 18:56 Sempron2800+ 阅读(121) 评论(0) 推荐(0) 编辑
摘要: vector numberOfLines(vector& widths, string S) { map MAP; MAP.insert(make_pair('a', widths[0])); MAP.insert(make_pair('b', widths[1])); MAP.insert(make_pair('c', widths[2])); MAP.... 阅读全文
posted @ 2018-09-27 18:46 Sempron2800+ 阅读(195) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: ListNode* middleNode(ListNode* head) { if (head == NULL) { return nullptr; } vector List; List.push_back(head); ... 阅读全文
posted @ 2018-09-27 18:26 Sempron2800+ 阅读(110) 评论(0) 推荐(0) 编辑
摘要: int smallestRangeI(vector& A, int K) { int min = INT_MAX; int max = INT_MIN; for (auto a : A) { if (min > a) { min = a; } if (max 2 * K) ... 阅读全文
posted @ 2018-09-27 18:09 Sempron2800+ 阅读(89) 评论(0) 推荐(0) 编辑
摘要: int projectionArea(vector>& grid) { int sum = 0; int row_max = 0; int col_max = 0; for (int i = 0; i < grid.size(); i++) { row_max = 0; for (int j = 0; j < grid[0... 阅读全文
posted @ 2018-09-27 17:36 Sempron2800+ 阅读(110) 评论(0) 推荐(0) 编辑
摘要: vector> transpose(vector>& A) { vector> V; int RowLen = A.size(); int ColLen = A[0].size(); for (int j = 0; j v; for (int i = 0; i < RowLen; i++) { v.... 阅读全文
posted @ 2018-09-27 14:53 Sempron2800+ 阅读(107) 评论(0) 推荐(0) 编辑
摘要: vector selfDividingNumbers(int left, int right) { vector V; for (int i = left; i = 1 && i <= 9) { V.push_back(i); continue; } bool tag = true; ... 阅读全文
posted @ 2018-09-27 14:13 Sempron2800+ 阅读(95) 评论(0) 推荐(0) 编辑
摘要: int peakIndexInMountainArray(vector& A) { int Len = A.size(); int position = -1; for (int i = 1; i A[i - 1] && A[i] > A[i + 1]) { position = i; break; ... 阅读全文
posted @ 2018-09-27 13:48 Sempron2800+ 阅读(121) 评论(0) 推荐(0) 编辑
摘要: vector> flipAndInvertImage(vector>& A) { vector> B; for (int i = 0; i Row = A[i]; vector Row2; for (int j = Row.size() - 1; j >= 0; j--) { int n = Row[j];... 阅读全文
posted @ 2018-09-27 13:31 Sempron2800+ 阅读(93) 评论(0) 推荐(0) 编辑
摘要: int uniqueMorseRepresentations(vector& words) { map st; st.insert(make_pair('a', ".-")); st.insert(make_pair('b', "-...")); st.insert(make_pair('c', "-.-.")); st.insert(make_pair(... 阅读全文
posted @ 2018-09-27 13:10 Sempron2800+ 阅读(86) 评论(0) 推荐(0) 编辑
摘要: vector sortArrayByParity(vector& A) { vector EVEN;//偶数 vector ODD;//奇数 for (auto a : A) { if (a % 2 == 0)//EVEN { EVEN.push_back(a); } else... 阅读全文
posted @ 2018-09-27 12:00 Sempron2800+ 阅读(91) 评论(0) 推荐(0) 编辑
摘要: string toLowerCase(string str) { transform(str.begin(), str.end(), str.begin(), ::tolower); return str; } 阅读全文
posted @ 2018-09-27 11:52 Sempron2800+ 阅读(85) 评论(0) 推荐(0) 编辑
摘要: int numJewelsInStones(string J, string S) { set st; int count = 0; for (auto c : J) { st.insert(c); } for (auto s : S) { if (st.find(s) != st.end()) ... 阅读全文
posted @ 2018-09-27 11:49 Sempron2800+ 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 本题目是使用递归处理,根据当前的值来判断剪去的子树,保留剩下的子树。 阅读全文
posted @ 2018-09-27 10:52 Sempron2800+ 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 这道题目,主要是判断相邻的两个值的大小,并按照要求的方式,将数组的数值都修正为符合要求的值。 然后通过一次的遍历,计算所累积的移动次数。 阅读全文
posted @ 2018-09-27 10:20 Sempron2800+ 阅读(115) 评论(0) 推荐(0) 编辑