- 博客(15)
- 收藏
- 关注
原创 Leetcode33: Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB Credits
2015-05-27 20:15:33 487
原创 Leetcode32: Excel Sheet Column Number
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ...
2015-05-27 16:55:22 537
原创 Leetcode31: Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element
2015-05-25 16:30:13 475
转载 Leetcode30: Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as0011100101
2015-05-20 21:42:40 432
原创 Leetcode29:String to Integer (atoi)
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca
2015-05-20 10:59:41 547
转载 Leetcode28: Isomorphic Strings
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with anot
2015-05-18 16:59:47 403
原创 Leetcode27: Count Primes
Description: Count the number of prime numbers less than a non-negative number, n class Solution { public: int countPrimes(int n) { bool *a = new bool[n]; for(int i = 2; i*i
2015-05-18 11:16:35 372
原创 Leetcode26: ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I
2015-05-12 22:18:10 364
原创 Leetcode25: Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 求若干字符串的最长公共前缀。 首先若无字符串,返回“”;接下来求得其中最短字符串的长度len,比较公共前缀只需最多比较len次;最后比较所有字符串里每一位上的字符。 class Solution { public:
2015-05-08 17:04:27 514
原创 Leetcode24: Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all va
2015-05-07 17:06:04 372
原创 Leetcode23: Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as
2015-05-07 09:49:43 584
原创 Leetcode22: Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is
2015-05-06 20:18:38 431
原创 Leetcode21: Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get
2015-05-06 17:25:10 387
原创 Leetcode20: Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(m
2015-05-04 16:20:24 410
原创 Leetcode19: Pow(x,n)
Implement pow(x, n). class Solution { public: double myPow(double x, int n) { if(n == 0) return 1.0; if(n < 0) return 1.0/myPow(x, -n); do
2015-05-01 16:05:56 366
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人