摘要:
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)
摘要:
Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For example, givenn... 阅读全文
posted @ 2015-12-09 16:12
雪之灵
阅读(132)
评论(0)
推荐(0)
摘要:
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ... 阅读全文
posted @ 2015-12-09 16:11
雪之灵
阅读(102)
评论(0)
推荐(0)
摘要:
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2015-12-09 16:08
雪之灵
阅读(116)
评论(0)
推荐(0)
摘要:
Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + ... 阅读全文
posted @ 2015-12-09 16:07
雪之灵
阅读(168)
评论(0)
推荐(0)
摘要:
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston... 阅读全文
posted @ 2015-12-09 15:59
雪之灵
阅读(151)
评论(0)
推荐(0)

浙公网安备 33010602011771号