摘要:
class Solution { public: bool checkSubarraySum(vector& nums, int k) { unordered_map m; // 从头元素开始的sum,取模为key的index。 m[0] = -1; int _sum = 0; for (int i = 0; i < n... 阅读全文
posted @ 2018-05-29 23:13
JTechRoad
阅读(87)
评论(0)
推荐(0)
摘要:
class Solution { public: unordered_map dp; int findTargetSumWays(vector& nums, int S) { return helper(nums, S, 0); } int helper(vector& nums, int S, int start) { strin... 阅读全文
posted @ 2018-05-29 14:56
JTechRoad
阅读(75)
评论(0)
推荐(0)
摘要:
class Solution { public: int totalHammingDistance(vector& nums) { int res = 0; for (int i = 0; i < 32; i++) { int ones = 0; for (int n : nums) { ... 阅读全文
posted @ 2018-05-29 13:35
JTechRoad
阅读(79)
评论(0)
推荐(0)
摘要:
class Solution { public: int hammingDistance(int x, int y) { int r = x ^ y; return bitCount(r); } int bitCount(int x) { int res = 0; while (x) { ... 阅读全文
posted @ 2018-05-28 22:44
JTechRoad
阅读(86)
评论(0)
推荐(0)
摘要:
class Solution { public: int splitArray(vector& nums, int m) { int _max = -1, _sum = 0; for (auto n : nums) { if (n > _max) _max = n; _sum += n; ... 阅读全文
posted @ 2018-05-27 15:28
JTechRoad
阅读(74)
评论(0)
推荐(0)
摘要:
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
posted @ 2018-05-26 15:01
JTechRoad
阅读(82)
评论(0)
推荐(0)
摘要:
class RandomizedSet { public: vector data; unordered_map m; // /** Initialize your data structure here. */ RandomizedSet() { } /** Inserts a value to the set.... 阅读全文
posted @ 2018-05-26 14:31
JTechRoad
阅读(108)
评论(0)
推荐(0)
摘要:
递归 TLE DP 阅读全文
posted @ 2018-05-25 15:24
JTechRoad
阅读(89)
评论(0)
推荐(0)
摘要:
/** * // This is the interface that allows for creating nested lists. * // You should not implement it, or speculate about its implementation * class NestedInteger { * public: * // Return ... 阅读全文
posted @ 2018-05-25 14:35
JTechRoad
阅读(78)
评论(0)
推荐(0)
摘要:
class Solution { public: bool increasingTriplet(vector& nums) { int i = INT_MAX, j = INT_MAX; for (int n : nums) { if (n <= i) { i = n; } ... 阅读全文
posted @ 2018-05-25 13:59
JTechRoad
阅读(73)
评论(0)
推荐(0)
浙公网安备 33010602011771号