- 博客(175)
- 收藏
- 关注
原创 199【LeetCode】Binary Tree Right Side View
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For example: Given the following binary tree, 1
2015-04-04 10:43:22
230
原创 198【LeetCode】House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house
2015-04-04 10:39:32
169
原创 191【LeetCode】Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 000000
2015-04-04 10:32:28
166
原创 190【LeetCode】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-04-04 10:22:05
252
原创 189【LeetCode】Rotate Array
Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions as yo
2015-04-04 10:19:11
137
原创 188【LeetCode】Best Time to Buy and Sell Stock IV
ay you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most k transactions. Note: You may n
2015-04-04 10:15:09
220
原创 187【LeetCode】Repeated DNA Sequences
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Write
2015-04-04 10:10:38
176
原创 179【LeetCode】Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be ve
2015-04-04 10:07:18
197
原创 174【LeetCode】Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially p
2015-04-04 10:04:44
158
原创 173【LeetCode】Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next()
2015-04-04 10:00:47
137
原创 172【LeetCode】Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. {优快云:CODE:635830}
2015-04-04 09:57:19
138
原创 171【LeetCode】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-04-04 09:53:05
127
原创 169【LeetCode】Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element
2015-04-04 09:47:47
175
原创 168【LeetCode】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 {优快云
2015-04-04 09:43:20
200
原创 166【LeetCode】Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses.
2015-04-04 09:37:43
140
原创 165【LeetCode】Compare Version Numbers
Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0. You may assume that the version strings are non-empty and co
2015-04-04 09:34:26
144
原创 164【LeetCode】Maximum Gap
Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Return 0 if the array contains less than 2 elements
2015-04-04 09:29:32
161
原创 162【LeetCode】Find Peak Element
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, i
2015-04-04 09:17:31
146
原创 160【LeetCode】Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2 ↘
2015-04-04 09:11:07
176
原创 155【LeetCode】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-04-04 08:58:24
144
原创 154【LeetCode】Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a sorted array is rotated at some pivot unk
2015-04-04 05:54:50
118
原创 153【LeetCode】Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in
2015-04-04 05:51:10
103
原创 152【LeetCode】Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the larges
2015-04-04 05:07:34
120
原创 1【LeetCode】Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, whe
2015-04-02 06:12:37
110
原创 2【LeetCode】Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2015-04-02 05:37:11
125
原创 3【LeetCode】Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo
2015-04-02 04:47:21
158
原创 4【LeetCode】Median of Two Sorted Arrays
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). {优快云:CODE:633839}
2015-04-02 04:46:20
175
原创 5【LeetCode】Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. {优快云:CODE:6
2015-04-02 04:42:05
153
原创 6【LeetCode】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-04-02 04:38:03
133
原创 7【LeetCode】Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before c
2015-04-02 00:49:00
104
原创 8【LeetCode】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-04-02 00:44:21
104
原创 9【LeetCode】Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of convertin
2015-04-02 00:41:40
133
原创 10【LeetCode】Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input st
2015-04-02 00:35:49
155
原创 11【LeetCode】Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin
2015-04-02 00:34:24
118
原创 12【LeetCode】Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. {优快云:CODE:633809}
2015-04-02 00:31:27
161
原创 13【LeetCode】Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. {优快云:CODE:633806}
2015-04-02 00:28:47
115
原创 14【LeetCode】Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. {优快云:CODE:633801}
2015-04-02 00:28:06
121
原创 15【LeetCode】3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c)
2015-04-02 00:20:58
110
原创 16【LeetCode】3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2015-04-02 00:18:28
101
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人