LintCode
文章平均质量分 79
Bernini_buffalo
这个作者很懒,什么都没留下…
展开
-
LintCode_412 Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on转载 2016-08-15 14:34:04 · 312 阅读 · 0 评论 -
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 · 177 阅读 · 0 评论 -
Lintcode_417 Valid Number
Validate if a given string is numeric.Have you met this question in a real interview? YesExample"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true转载 2016-08-17 03:15:45 · 277 阅读 · 0 评论 -
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-08-16 06:42:39 · 223 阅读 · 0 评论 -
LintCode_362 Sliding Window Maximum
Given an array of n integer with duplicate number, and a moving window(size k), move the window at each iteration from the start of the array, find the maximum number inside the window at each moving.原创 2016-08-16 04:59:28 · 247 阅读 · 0 评论 -
LintCode_552 Create Maximum Number
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of lengthk from digits of the two. The relative order of the digits from the same array mu原创 2016-08-16 04:05:25 · 236 阅读 · 0 评论 -
LintCode_365 Count 1 in Binary
Count how many 1 in binary representation of a 32-bit integer.ExampleGiven 32, return 1Given 5, return 2Given 1023, return 9Challenge If the integer is n bits with m 1 bi原创 2016-08-04 04:48:36 · 275 阅读 · 0 评论 -
LintCode_362 Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.ExampleGiven [0,1,0,2,1,0,1,3,2,1,原创 2016-08-04 04:45:28 · 204 阅读 · 0 评论 -
LintCode_249 Count of Smaller Number before itself
Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) . For each element Ai in the array, count the number of element before this element Ai is原创 2016-08-04 04:41:23 · 361 阅读 · 0 评论 -
LintCode_223 Palindrome Linked List
Implement a function to check if a linked list is a palindrome.ExampleGiven 1->2->1, return trueChallenge Could you do it in O(n) time and O(1) space?找到中间点, 然后开始检查:/*原创 2016-08-04 04:26:39 · 153 阅读 · 0 评论 -
LintCode_204 Singleton
Singleton is a most widely used design pattern. If a class has and only has one instance at every moment, we call this design as singleton. For example, for class Mouse (not a animal mouse), we shou原创 2016-08-04 04:21:53 · 180 阅读 · 0 评论 -
LintCode_200 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.ExampleG原创 2016-08-04 04:11:16 · 210 阅读 · 0 评论 -
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 · 1240 阅读 · 0 评论 -
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 · 364 阅读 · 0 评论 -
LintCode_564 Backpack VI
Given an integer array nums with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. NoticeThe different sequences ar原创 2016-08-06 10:24:07 · 799 阅读 · 0 评论 -
LintCode_168 Burst Balloons
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get原创 2016-08-06 12:53:49 · 404 阅读 · 0 评论 -
LintCode_207 interval-sum-ii
Given an integer array in the construct method, implement two methods query(start, end) and modify(index, value):For query(start, end), return the sum from index start to index end in the given原创 2016-08-15 14:24:04 · 194 阅读 · 0 评论 -
LintCode_510 Maximal Rectangle
Given a 2D boolean matrix filled with False and True, find the largest rectangle containing all True and return its area.Have you met this question in a real interview? YesExam原创 2016-08-21 14:13:28 · 611 阅读 · 0 评论 -
LintCode_400 Maximum Gap
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Return 0 if the array contains less than 2 elements. NoticeYou may assume all elemen原创 2016-08-21 08:42:25 · 353 阅读 · 0 评论 -
LintCode_192 Wildcard Matching
Implement wildcard pattern matching with support for '?' and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover原创 2016-08-09 14:20:33 · 315 阅读 · 0 评论 -
LintCode_131 Building Outline
Given N buildings in a x-axis,each building is a rectangle and can be represented by a triple (start, end, height),where start is the start position on x-axis, end is the end position on x-axis and原创 2016-08-09 11:02:01 · 310 阅读 · 0 评论 -
LintCode_249 Count of Smaller Number before itself
Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) . For each element Ai in the array, count the number of element before this element Ai is原创 2016-08-20 03:04:29 · 269 阅读 · 0 评论 -
LintCode_248 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-08-20 02:59:34 · 274 阅读 · 0 评论 -
LintCode_212 Space Replacement
Write a method to replace all spaces in a string with %20. The string is given in a characters array, you can assume it has enough space for replacement and you are given the true length of the stri原创 2016-08-20 02:55:14 · 394 阅读 · 0 评论 -
LintCode_366 Fibonacci
Find the Nth number in Fibonacci sequence.A Fibonacci sequence is defined as follow:The first two numbers are 0 and 1.The i th number is the sum of i-1 th number and i-2 th number.The first te原创 2016-08-08 02:32:15 · 318 阅读 · 2 评论 -
LintCode_393 Best Time to Buy and Sell Stock IV
Say 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 no转载 2016-08-19 09:47:14 · 289 阅读 · 0 评论 -
LintCode_430 Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr原创 2016-08-19 06:34:49 · 251 阅读 · 0 评论 -
LintCode_134 LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if原创 2016-08-07 04:14:43 · 324 阅读 · 0 评论 -
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 · 213 阅读 · 0 评论 -
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 · 203 阅读 · 0 评论 -
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 · 424 阅读 · 0 评论 -
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 · 223 阅读 · 0 评论 -
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 · 328 阅读 · 0 评论 -
Lintcode_32 Minimum Window Substring
Given a string source and a string target, find the minimum window in source which will contain all the characters in target.ClarificationShould the characters in minimum window has the sa原创 2016-06-29 04:16:17 · 230 阅读 · 0 评论 -
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 · 206 阅读 · 0 评论 -
Lintcode_30 Insert Interval
Given a non-overlapping interval list which is sorted by start point.Insert a new interval into it, make sure the list is still in order and non-overlapping (merge intervals if necessary).Ex原创 2016-06-28 14:23:59 · 218 阅读 · 0 评论 -
Lintcode_29 Interleaving String
Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 ands2.ExampleFor s1 = "aabcc", s2 = "dbbca"When s3 = "aadbbcbcac", return true.When s3 = "原创 2016-06-28 08:03:45 · 279 阅读 · 0 评论 -
Lintcode_28 Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix.This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each原创 2016-06-28 07:54:52 · 171 阅读 · 0 评论 -
Lintcode_18 Subsets II
Given a list of numbers that may has duplicate numbers, return all possible subsetsExampleIf S = [1,2,2], a solution is:[ [2], [1], [1,2,2], [2,2], [1,2], []]不多说了直接上代码:原创 2016-06-28 07:25:00 · 196 阅读 · 0 评论 -
Lintcode_16 Permutations II
Given a list of numbers with duplicate number in it. Find all unique permutations.ExampleFor numbers [1,2,2] the unique permutations are:[ [1,2,2], [2,1,2], [2,2,1]]思路是转化为字符串(中间加“原创 2016-06-28 07:21:25 · 183 阅读 · 0 评论