10 2012 档案
摘要:class Solution {
public: vector<int> plusOne(vector<int> &digits) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<int> result; int carray_bit = 0; digits[digits.size()-1] += 1; for(int i=digits.size()-1;i>=0;i...
阅读全文
摘要://需要注意细节class Solution {
public: string longestCommonPrefix(vector<string> &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function //sort(strs.begin(),strs.end()); string result(""); if (strs.size()==0) { return r...
阅读全文
摘要:使用统计学的方法:O(n)分治的方法,比较复杂class Solution {
public: int maxSubArray(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int maxendinghere=A[0]; int max = maxendinghere; for(int i=1;i<n;i++) { if (maxendin...
阅读全文
摘要:http://www.leetcode.com/onlinejudgeclass Solution {
public: vector<string> anagrams(vector<string> &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function multimap<string,string> map; for(int i=0;i<strs.size();i++) { if(s...
阅读全文
摘要:直接使用加法/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */
class Solution {
public: ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) { // Start typing your C/C++ solution below ...
阅读全文
摘要:LeetCode interview Questions:Add binay1.int之类的数可以使用small2.直接在字符串使用二进制的加法http://www.leetcode.com/onlinejudge 需要FQclass Solution {
public: int string_to_int(string str) { int result = 0; int level = 1; for(int i = str.length() - 1; i >=0 ; i--) { if (str[i] == '...
阅读全文
浙公网安备 33010602011771号