摘要:
class Solution { public: bool Find(int target, vector > array) { int HangShu = array[0].size(); int LieShu = array.size(); int i = 0; int j = (LieShu - 1); ... 阅读全文
摘要:
class Solution { public: // Parameters: // numbers: an array of integers // length: the length of array numbers // duplication: (Output) the duplicated n... 阅读全文
摘要:
class Solution { public: vector multiply(const vector& A) { vector result; int size = A.size(); for (int i = 0; i < size; ++i) { int chengji=1; ... 阅读全文
摘要:
方法二: 思路二:如果有符合条件的数字,则它出现的次数比其他所有数字出现的次数和还要多。 在遍历数组时保存两个值:一是数组中一个数字,一是次数。遍历下一个数字时,若它与之前保存的数字相同,则次数加1,否则次数减1;若次数为0,则保存下一个数字,并将次数置为1。遍历结束后,所保存的数字即为所求。然后再 阅读全文
摘要:
class Solution { public: int NumberOf1Between1AndN_Solution(int n) { int count=0; for (int i=1;i1) //对高位最低一位进行分类 { count+=(a/10+1)*i; } if ... 阅读全文
摘要:
//弄成字符串比较 稍易 class Solution { public: static bool compare(const string &a, const string &b) { string s1 = (a + b); string s2 = (b + a); return s1 numbers) { ... 阅读全文
摘要:
class Solution { public: int FindGreatestSumOfSubArray(vector array) { if(array.size()==0) { return 0; } else { int cursum=arr... 阅读全文
摘要:
class Solution { public: vector GetLeastNumbers_Solution(vector input, int k) { int in_size = input.size(); for (int i = 0; i input[j]) { s... 阅读全文
摘要:
没用哈希 阅读全文
摘要:
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: int Getlength(ListNode* pNode) { ... 阅读全文