- 博客(25)
- 资源 (1)
- 收藏
- 关注
原创 LintCode_198 Permutation Index II
Given a permutation which may contain repeated numbers, find its index in all the permutations of these numbers, which are ordered in lexicographical order. The index begins at 1.ExampleGi
2016-07-30 15:04:48 1270
原创 LintCode_191 Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.ExampleFor example, given the array [2,3,-2,4], the contiguous subarray [2,3]
2016-07-30 04:47:36 220
原创 LintCode_190 Next Permutation II
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o
2016-07-30 04:43:12 209
原创 LintCode_189 First Missing Positive
Given an unsorted integer array, find the first missing positive integer.ExampleGiven [1,2,0] return 3,and [3,4,-1,1] return 2.Challenge Your algorithm should run in O(n) tim
2016-07-30 04:37:33 202
原创 LinCode_187 Gas Station
There are N gas stations along a circular route, where the amount of gas at station i isgas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its
2016-07-30 04:33:54 204
原创 LintCode_154 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
2016-07-30 04:12:59 278
原创 leecode_229 Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.这样的元素最多两个//solution from bernin
2016-07-26 02:22:20 185
原创 LintCode_284 Count of Smaller Number
Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) and an query list. For each query, give you an integer, return the number of element in the ar
2016-07-25 12:09:31 363
原创 LintCode_206 Interval Sum
Given an integer array (index from 0 to n-1, where n is the size of this array), and an query list. Each query has two integers[start, end]. For each query, calculate the sum number between index st
2016-07-25 10:54:42 240
原创 LintCode_205 Interval Minimum Number
Given an integer array (index from 0 to n-1, where n is the size of this array), and an query list. Each query has two integers [start, end]. For each query, calculate the minimum number between ind
2016-07-25 10:26:10 181
原创 LintCode_516 Paint House II
There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no tw
2016-07-22 06:46:18 375
原创 LintCode_512 Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total numb
2016-07-22 04:46:28 204
原创 LintCode_401 Kth Smallest Number in Sorted Matrix
Find the kth smallest number in at row and column sorted matrix.ExampleGiven k = 4 and a matrix:[ [1 ,5 ,7], [3 ,7 ,8], [4 ,8 ,9],]return 5Challenge O(k log n), n i
2016-07-18 09:26:14 416
原创 LintCode_186 Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.ExampleGiven 4 points: (1,2), (3,6), (0,0), (1,3).The maximum number is 3.题目不
2016-07-12 15:23:57 252
原创 LintCode_178 Graph Valid Tree
Given n nodes labeled from 0 to n - 1 and a list ofundirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. NoticeYou can as
2016-07-12 04:55:34 337
原创 LintCode_156 Merge Intervals
Given a collection of intervals, merge all overlapping intervals.ExampleGiven intervals => merged intervals:[ [ [1, 3], [1, 6], [2, 6], =>
2016-07-10 07:41:44 213
原创 LintCode_130 Heapify
Given an integer array, heapify it into a min-heap array.For a heap array A, A[0] is the root of heap, and for each A[i], A[i * 2 + 1] is the left child of A[i] and A[i * 2 + 2] is the right child o
2016-07-08 03:03:07 211
原创 LintCode_128 Hash Function
In data structure Hash, hash function is used to convert a string(or any other type) into an integer smaller than hash size and bigger or equal to zero. The objective of designing a hash function is t
2016-07-08 02:31:36 371
原创 LintCode_127 Topological Sorting
Given an directed graph, a topological order of the graph nodes is defined as follow:For each directed edge A -> B in graph, A must before B in the order list.The first node in the order can be
2016-07-07 06:16:32 223
原创 LintCode_124 Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.ClarificationYour algorithm should run in O(n) complexity.ExampleGiven [100, 4
2016-07-07 04:35:59 273
原创 Lintcode_123 Word Search
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically
2016-07-07 03:40:46 196
转载 Lintcode_122 Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of
2016-07-06 15:21:14 310
原创 Lintcode_119 Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:
2016-07-06 12:26:13 262
转载 Lintcode_108 Palindrome Partitioning II
1 Palindrome Partitioning问题来源:Palindrome Partitioning该问题简单来说就是给定一个字符串,将字符串分成多个部分,满足每一部分都是回文串,请输出所有可能的情况。 该问题的难度比较大,很可能第一次遇到没有思路,这很正常。下面我们一点点分析,逐步理清思路。先不考虑所有的情况,针对一个符合条件的划分,每一部分都是一个回文
2016-07-03 11:46:43 286
原创 Lintcode_89 k Sum
Given n distinct positive integers, integer k (k n) and a numbertarget.Find k numbers where sum is target. Calculate how many solutions there are?ExampleGiven [1,2,3,4], k = 2, target =
2016-07-02 05:10:46 435
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人