- 博客(48)
- 收藏
- 关注
转载 Leetcode题目:Letter Combinations of a Phone Number
题目:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Di...
2016-06-14 16:11:00 95
转载 Leetcode题目:Container With Most Water
题目:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0)....
2016-06-14 11:26:00 94
转载 Leetcode题目:Longest Palindromic Substring
题目:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest palindromic substring.题目解答:题目要求找到一...
2016-06-13 18:31:00 84
转载 Leetcode题目:Search Insert Position
题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in th...
2016-06-01 14:24:00 83
转载 Leetcode题目:Flatten Binary Tree to Linked List
题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: ...
2016-06-01 14:15:00 63
转载 Leetcode题目:House Robber III
题目:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. Af...
2016-06-01 11:22:00 72
转载 Leetcode题目:House Robber II
题目:Note:This is an extension ofHouse Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. T...
2016-05-31 16:48:00 83
转载 Leetcode题目:Compare Version Numbers
题目:Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1<version2return -1, otherwise return 0.You may assume that the version strings are no...
2016-05-30 16:19:00 84
转载 Leetcode题目:Intersection of Two Arrays II
题目:Given two arrays, write a function to compute their intersection.Example:Givennums1=[1, 2, 2, 1],nums2=[2, 2], return[2, 2].Note:Each element in the result should appear as ma...
2016-05-30 15:16:00 67
转载 Leetcode题目:Intersection of Two Arrays
题目:Given two arrays, write a function to compute their intersection.Example:Givennums1=[1, 2, 2, 1],nums2=[2, 2], return[2].Note:Each element in the result must be unique.The...
2016-05-30 15:02:00 105
转载 Leetcode题目:First Bad Version
题目:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed base...
2016-05-10 21:57:00 87
转载 Leetcode题目:Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.题目解答:求一组字符串的最长公共前缀。使用迭代器数组实现。思路异常的简单。代码如下:class Solution {public: string longestCommonPrefix(...
2016-05-10 12:03:00 61
转载 Leetcode题目:Counting Bits
题目:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example: For nu...
2016-05-10 12:01:00 110
转载 Leetcode题目:Range Sum Query - Immutable
题目:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) ...
2016-05-10 11:36:00 57
转载 Leetcode题目:Palindrome Linked List
题目:Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?题目解答:题目中要求在O(n)的时间复杂度和O(1)的空间复杂度内解决问题,显然的,复制和使用栈来实现时不可取的。唯一可以想到的思路,就是扭转...
2016-04-28 19:02:00 77
转载 Leetcode题目:Rectangle Area
题目:Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that th...
2016-04-28 14:36:00 82
转载 Leetcode题目:Binary Tree Paths
题目:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->...
2016-04-27 19:29:00 68
转载 Leetcode题目:Merge Sorted Array
题目:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is greater or equal tom+n) to hold...
2016-04-25 21:07:00 65
转载 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 ↘ ...
2016-04-25 16:50:00 70
转载 Leetcode题目:Implement Stack using Queues
题目:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() ...
2016-04-25 16:28:00 69
转载 Leetcode题目:Minimum Depth of Binary Tree
题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.题目解答:这道题借助了之前做的层次遍历的题目的代码,...
2016-04-25 15:48:00 59
转载 Leetcode题目:Binary Tree Level Order Traversal
题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 ...
2016-04-25 15:40:00 57
转载 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.题目解答:这个题目是要求出给定的整数n的阶乘结果后面有几个0。可以发现,对于n!可以将它做质数分解:n! = (2^...
2016-04-25 15:24:00 58
转载 Leetcode题目:Symmetric Tree
题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3...
2016-04-24 00:46:00 63
转载 Leetcode题目:Implement Queue using Stacks
题目:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front el...
2016-04-23 22:30:00 64
转载 Leetcode题目:Balanced Binary Tree
题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node nev...
2016-04-23 21:32:00 67
转载 Leetcode题目:Swap Nodes in Pairs
题目:Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use ...
2016-04-23 20:42:00 66
转载 Leetcode题目:Reverse Vowels of a String
题目:Write a function that takes a string as input and reverse only the vowels of a string.Example 1: Given s = "hello", return "holle". Example 2: Given s = "leetcode", return "leotcede". ...
2016-04-23 20:00:00 65
转载 Leetcode题目:Best Time to Buy and Sell Stock
题目:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the s...
2016-04-23 17:27:00 56
转载 Leetcode题目:Happy Number
题目:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the...
2016-04-23 17:04:00 69
转载 Leetcode题目:Reverse String
题目:Write a function that takes a string as input and returns the string reversed.Example: Given s = "hello", return "olleh". 解答:这个题目超级无敌简单,就是把一个string给逆过来输出。代码:class Solution {public:...
2016-04-22 16:48:00 59
转载 Leetcode题目:Bulls and Cows
题目:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide ...
2016-04-21 19:01:00 107
转载 Leetcode题目: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 wit...
2016-04-21 17:03:00 60
转载 Leetcode题目:Power of Three
题目:Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion? 题目解答:本题是不适用循环或递归的方式判断当前这个数字是否是3的幂。可以从以下的数列中观察出规律...
2016-04-21 16:43:00 70
转载 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 adja...
2016-04-20 21:24:00 79
转载 Leetcode题目:Remove Duplicates from Sorted List
题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2-&g...
2016-04-20 21:04:00 50
转载 Leetcode题目:Lowest Common Ancestor of a Binary Search Tree
题目:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined ...
2016-04-20 20:37:00 73
转载 Leetcode题目:Ugly Number
题目:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly ...
2016-04-20 19:25:00 85
转载 Leetcode题目:Remove Linked List Elements
题目:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 -...
2016-04-20 19:15:00 77
转载 Leetcode题目: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 "on...
2016-04-20 19:03:00 67
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人