随笔分类 -  LintCode

摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... Notice Please complete the problem in-place. 阅读全文
posted @ 2016-05-16 23:57 Grandyang 阅读(562) 评论(0) 推荐(0) 编辑
摘要:Given a 2D boolean matrix filled with False and True, find the largest rectangle containing all True and return its area. ExampleGiven a matrix: [ [1, 阅读全文
posted @ 2016-05-15 23:58 Grandyang 阅读(1501) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and two values v1 and v2. Swap the two nodes in the linked list with values v1 and v2. It's guaranteed there is no duplicate value 阅读全文
posted @ 2016-05-14 23:34 Grandyang 阅读(2854) 评论(0) 推荐(1) 编辑
摘要: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 co 阅读全文
posted @ 2016-04-30 12:18 Grandyang 阅读(1162) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. ExampleGiven n = 12, retur 阅读全文
posted @ 2016-04-30 12:16 Grandyang 阅读(2122) 评论(0) 推荐(0) 编辑
摘要:There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent f 阅读全文
posted @ 2016-04-30 12:14 Grandyang 阅读(796) 评论(0) 推荐(0) 编辑
摘要:There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certai 阅读全文
posted @ 2016-04-30 12:13 Grandyang 阅读(1050) 评论(0) 推荐(0) 编辑
摘要: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. Yo 阅读全文
posted @ 2016-04-30 12:10 Grandyang 阅读(1018) 评论(0) 推荐(0) 编辑
摘要: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 ex 阅读全文
posted @ 2016-04-30 12:07 Grandyang 阅读(510) 评论(0) 推荐(0) 编辑
摘要: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. This t 阅读全文
posted @ 2016-04-29 12:38 Grandyang 阅读(846) 评论(0) 推荐(0) 编辑
摘要: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 yo 阅读全文
posted @ 2016-04-29 12:24 Grandyang 阅读(783) 评论(0) 推荐(0) 编辑
摘要: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 hou 阅读全文
posted @ 2016-04-29 11:22 Grandyang 阅读(983) 评论(0) 推荐(0) 编辑
摘要:Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes 阅读全文
posted @ 2016-04-27 13:54 Grandyang 阅读(821) 评论(2) 推荐(0) 编辑
摘要:You know what, left pad is javascript package and referenced by React: Github link One day his author unpublished it, then a lot of javascript project 阅读全文
posted @ 2016-04-26 13:05 Grandyang 阅读(1402) 评论(0) 推荐(0) 编辑
摘要:Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ 阅读全文
posted @ 2016-04-26 12:47 Grandyang 阅读(1026) 评论(0) 推荐(0) 编辑
摘要:For an array A, if i < j, and A [i] > A [j], called (A [i], A [j]) is a reverse pair.return total of reverse pairs in A. ExampleGiven A = [2, 4, 1, 3, 阅读全文
posted @ 2016-04-26 11:32 Grandyang 阅读(4086) 评论(0) 推荐(0) 编辑
摘要:Given a sequence of integers, find the longest increasing subsequence (LIS).You code should return the length of the LIS.Have you met this question in... 阅读全文
posted @ 2015-10-19 12:04 Grandyang 阅读(5756) 评论(0) 推荐(2) 编辑
摘要:Implement a trie with insert, search, and startsWith methods.Have you met this question in a real interview?ExampleNoteYou may assume that all inputs ... 阅读全文
posted @ 2015-10-11 10:45 Grandyang 阅读(1604) 评论(0) 推荐(0) 编辑
摘要:Cosine similarity is a measure of similarity between two vectors of an inner product space that measures the cosine of the angle between them. The cos... 阅读全文
posted @ 2015-09-25 12:47 Grandyang 阅读(2644) 评论(0) 推荐(0) 编辑
摘要:Givennpoints 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 max... 阅读全文
posted @ 2015-09-08 02:39 Grandyang 阅读(1223) 评论(0) 推荐(0) 编辑

Fork me on GitHub