摘要:
class Solution { public: int calPoints(vector& ops) { stack ST; int sum = 0; for (auto o : ops) { if (o == "C") { int n = S...
阅读全文
posted @ 2018-09-28 18:27
Sempron2800+
阅读(88)
推荐(0)
摘要:
本题经过一下午的思考,终于解出来了。使用的是层次遍历的思想。
阅读全文
posted @ 2018-09-28 17:34
Sempron2800+
阅读(112)
推荐(0)
摘要:
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-28 07:36
Sempron2800+
阅读(112)
推荐(0)
摘要:
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+
阅读(110)
推荐(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+
阅读(86)
推荐(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+
阅读(89)
推荐(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+
阅读(125)
推荐(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+
阅读(198)
推荐(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+
阅读(112)
推荐(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+
阅读(93)
推荐(0)