05 2015 档案
摘要:题目: Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, re
阅读全文
摘要:题目: Implement a trie with insert, search, and startsWith methods. 链接: http://leetcode.com/problems/implement-trie-prefix-tree/ 题解: 设计Trie。题目给了很多条件,所以大
阅读全文
摘要:题目: There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you ha
阅读全文
摘要:题目: Reverse a singly linked list. 链接: http://leetcode.com/problems/reverse-linked-list/ 题解: 反转单链表,必须做得非常熟练。这个method将会是许多复杂题目的一个组成部分。 Time Complexity -
阅读全文
摘要:题目: 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 occur
阅读全文
摘要:题目: Description: Count the number of prime numbers less than a non-negative number, n. Credits:Special thanks to @mithmatt for adding this problem and
阅读全文
摘要:题目: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 -->
阅读全文
摘要:题目: 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 in
阅读全文
摘要:题目: Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range
阅读全文
摘要:题目: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adj
阅读全文
posted @ 2015-05-10 06:46
YRB
摘要:题目: 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
阅读全文
摘要:题目: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stoppin
阅读全文
摘要:题目: 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-
阅读全文
摘要:题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), r
阅读全文
摘要:题目: 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].
阅读全文
摘要:题目:链接:题解:测试:Reference:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters. The input string does not contain
阅读全文
摘要:题目: 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 form
阅读全文
摘要:题目: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 i...
阅读全文
摘要:题目: 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 t
阅读全文
摘要:题目: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 链接: http://leetcode.
阅读全文
摘要:题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example
阅读全文
摘要:题目: Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure.
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 链接: http://leetcode.com/problems/excel-s
阅读全文
摘要:题目: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The func
阅读全文
摘要:题目: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repea
阅读全文
摘要:题目: Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may a
阅读全文
摘要:题目: Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Ret
阅读全文
摘要:题目: Given a sorted integer array where the range of elements are [lower, upper] inclusive, return its missing ranges. For example, given [0, 1, 3, 50,
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given two strings S and T, determine if they are both one edit distance apart. 链接: http://leetcode.com/problems/one-edit-distance/ 题解: 求两个字符串是否只有1
阅读全文
摘要:题目: 链接: http://leetcode.com/problems/intersection-of-two-linked-lists/ 题解: 题目理解起来比较容易,两个单链表求交叉点。数学上来讲使用两个runner,一个链表走完以后继续走另外一个链表,假如有交叉点则两个节点相等的时候正好走了
阅读全文
摘要:题目:Given a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s =“eceba”,T is "ece" whi...
阅读全文
摘要:题目: The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it
阅读全文
摘要:题目: The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it
阅读全文
摘要:题目: Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip i
阅读全文
摘要:题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- R
阅读全文
摘要:题目:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a s...
阅读全文
摘要:题目: 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 elem
阅读全文
摘要:题目: 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,
阅读全文
摘要:题目: Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For
阅读全文
摘要:题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or anoth
阅读全文
摘要:题目: Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 链接: http://leetcode.com/problems/max-points-on
阅读全文
摘要:题目: Sort a linked list in O(n log n) time using constant space complexity. 链接: http://leetcode.com/problems/sort-list/ 题解: Sort List, 链表排序,一看到O(nlogn)
阅读全文
摘要:题目: Sort a linked list using insertion sort. Hide Tags Linked List Sort Sort a linked list using insertion sort. Hide Tags Linked List Sort Sort a lin
阅读全文
摘要:题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get
阅读全文
摘要:题目: Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive
阅读全文
摘要:题目: Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note:
阅读全文

浙公网安备 33010602011771号