码迷,mamicode.com
首页 >  
搜索关键字:refresh    ( 1347个结果
LeetCode – Refresh – Implement strStr()
Brute Force: 1 class Solution { 2 public: 3 int strStr(char *haystack, char *needle) { 4 if (!haystack) return -1; 5 if (!needle) ...
分类:其他好文   时间:2015-03-20 01:13:34    阅读次数:110
LeetCode – Refresh – Gas Station
Not quite hard. Just remember initialize index to 0. Because if you initialize it as -1 and all the gas satisfy the cost, it will return -1.Actually, ...
分类:其他好文   时间:2015-03-20 01:11:41    阅读次数:210
LeetCode – Refresh – Gray Code
i ^ (i >> 1), that's the general format 1 class Solution { 2 public: 3 vector grayCode(int n) { 4 vector result; 5 for (int i = 0;...
分类:其他好文   时间:2015-03-20 01:09:59    阅读次数:140
LeetCode – Refresh – Fraction to Recurring Decimal
Notes:1. When numerator is 0, return "0". Check this corner case, because 0 / -5 will return -0.2. Use long long int for divd and divs, mainly for div...
分类:其他好文   时间:2015-03-19 23:44:46    阅读次数:162
LeetCode – Refresh – Find Minimum in Rotated Array II
lazy solutions..... Just skip the duplicates. Then worse case of time is O(n). 1 class Solution { 2 public: 3 int findMin(vector &num) { 4 ...
分类:其他好文   时间:2015-03-19 10:07:57    阅读次数:118
LeetCode – Refresh – Exceel Sheet Column Number
No tricks. 1 class Solution { 2 public: 3 int titleToNumber(string s) { 4 int result = 0, len = s.size(); 5 for (int i = 0; i < le...
分类:其他好文   时间:2015-03-19 10:05:24    阅读次数:256
LeetCode – Refresh – Find Minimum in Rotated Array
Be carefully with one element and two element sitution.1. Since mid = (start + end) / 2 is alway shifting to the left. So when we do comparision, not ...
分类:其他好文   时间:2015-03-19 10:01:34    阅读次数:141
LeetCode – Refresh – Factorial Trailing Zeroes
Think about that.. n! = n * (n-1) * (n-2) ..... *1Zeros happened when each of them can be divided by 10. And 10 = 2 * 5. 2 is much more than 5 in the ...
分类:其他好文   时间:2015-03-19 10:01:03    阅读次数:140
LeetCode – Refresh – Evaluate Reverse Polish Notation
Just use a stack to record the numbers. And evey time you encounter a operator, pop two numbers, calucate it and push it back.Do not disorder the numb...
分类:其他好文   时间:2015-03-19 09:59:59    阅读次数:113
LeetCode – Refresh – Exceel Sheet Column Title
Only trick is the 'Z'. Because when the number % 26 == 0, means there is a 'Z'. But when you n/=26, there is an extra 1 added to the n. EX:27 % 26 = 1...
分类:其他好文   时间:2015-03-19 09:59:13    阅读次数:110
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!