摘要: /*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x), next(NULL) {}* };*/class Solution {pu... 阅读全文
posted @ 2015-12-10 15:14 雪之灵 阅读(107) 评论(0) 推荐(0)
摘要: class Solution {public: int romanToInt(string s) { int length = s.size(); int result = 0; int pre =getnum (s[0]); for (int i = 1 ;i<length ;i++) {int ... 阅读全文
posted @ 2015-12-10 15:12 雪之灵 阅读(130) 评论(0) 推荐(0)
摘要: For example, the 32-bit integer ’11' has binary representation00000000000000000000000000001011, so the function should return 3.class Solution {public... 阅读全文
posted @ 2015-12-10 15:06 雪之灵 阅读(125) 评论(0) 推荐(0)
摘要: _______6______ / \ ___2__ ___8__ / \ / \ 0 _4 7 9 / \ 3 ... 阅读全文
posted @ 2015-12-10 15:05 雪之灵 阅读(116) 评论(0) 推荐(0)
摘要: Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.class Solution {public: int... 阅读全文
posted @ 2015-12-09 16:21 雪之灵 阅读(112) 评论(0) 推荐(0)
摘要: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 class Solution {public: int titleToNumber(string s) { int sum = 0,temp=0; for... 阅读全文
posted @ 2015-12-09 16:20 雪之灵 阅读(125) 评论(0) 推荐(0)
摘要: class Solution {public: bool containsDuplicate(vector& nums) { int length = nums.size(); sort(nums.begin(),nums.end());//比较相等的数据可以先对数组进行排序 for (int i... 阅读全文
posted @ 2015-12-09 16:18 雪之灵 阅读(139) 评论(0) 推荐(0)
摘要: Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur... 阅读全文
posted @ 2015-12-09 16:17 雪之灵 阅读(123) 评论(0) 推荐(0)
摘要: nvert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1/*** Definition for a binary tree node.*... 阅读全文
posted @ 2015-12-09 16:16 雪之灵 阅读(108) 评论(0) 推荐(0)
摘要: /*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(N... 阅读全文
posted @ 2015-12-09 16:14 雪之灵 阅读(127) 评论(0) 推荐(0)