[LintCode] Reorder List [链表综合题型]

2016-04-28
阅读 2 分钟
2.6k
Given 1->2->3->4->null, reorder it to 1->4->2->3->null.

[LintCode] Sort List [分治]

2016-04-28
阅读 2 分钟
2.1k
Sort a linked list in O(n log n) time using constant space complexity.

[LintCode/LeetCode] Remove Duplicates from Sorted Array I & II

2016-04-28
阅读 2 分钟
1.8k
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.

[LintCode/LeetCode] Convert Sorted List to Balanced BST [二叉搜索树]

2016-04-28
阅读 1 分钟
3.2k
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.

[LintCode/LeetCode] Copy List with Random Pointer [链表复制与分离]

2016-04-27
阅读 2 分钟
2.8k
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.

[LintCode] Merge K Sorted Lists [DC/Heap]

2016-04-27
阅读 3 分钟
2.9k
Problem Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example Given lists: {代码...} return -1->2->4->null. Note 分治做法中,merge()函数依然是将链表结点两两进行比较,然后在sort()函数中迭代merge两个二分后sort()的结果。PriorityQueue更为...

[LintCode] Reverse Pairs

2016-04-26
阅读 1 分钟
3.3k
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.

[MongoDB] MongoDB在El Capitan的安装调试详解

2016-04-26
阅读 1 分钟
2.7k
Homebrew安装 {代码...} 手动安装 {代码...} 运行 {代码...} 注意 1. 如果端口被占用,killall mongod 或者 mongod --shutdown 或者 ps wuax | grep mongo然后 kill <port of mongod> 又或者换一个端口运行 mongod --port 27018 2. 如果出现[HostnameCanonicalizationWorker]的错误:Failed to obtain name info f...

[LeetCode/LintCode] Design Twitter/Mini Twitter

2016-04-22
阅读 8 分钟
4.3k
建立两个HashMap,一个存user,一个存tweets。以及整型的时间戳timestamp。user的k-v pair是userId-follower_set,tweets的k-v pair是userId-tweets_linkedlist,tweets属于Tweet类,包含time和id两个参数。

[LintCode] k Sum [三维动态规划]

2016-04-22
阅读 2 分钟
7.8k
Given n distinct positive integers, integer k (k <= n) and a number target.

[LintCode] k Sum II [Backtracking]

2016-04-22
阅读 2 分钟
2.5k
这道题不能用k Sum的做法,因为要返回的是结果的集合,而不是数目或者最优解。我们使用回溯算法,建立helper函数。从curIndex开始循环,将循环到的值A[i]加入curList,然后基于这个curList继续递归,不过要调整target和curIndex。target减小A[i],curIndex增加1位。当curList的大小为k时,若target也正好减小为0,说明当...

[LintCode] Toy Factory

2016-04-21
阅读 1 分钟
3.2k
Factory is a design pattern in common usage. Please implement a ToyFactory which can generate proper toy based on the given type.

[LintCode] Shape Factory

2016-04-20
阅读 2 分钟
3.4k
Factory is design pattern in common usage. Implement a ShapeFactory that can generate correct shape.

[LintCode] Left Pad

2016-04-20
阅读 2 分钟
3.3k
You know what, left pad is javascript package and referenced by React: Github link

[LintCode] Palindrome Partitioning II

2016-04-19
阅读 1 分钟
2.1k
Given a string s, cut s into some substrings such that every substring is a palindrome.

[LintCode/LeetCode] Word Break

2016-04-19
阅读 2 分钟
2.5k
Given a string s and a dictionary of words dict, determine if s can be break into a space-separated sequence of one or more dictionary words.

[LintCode/LeetCode] Triangle

2016-04-17
阅读 2 分钟
1.9k
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.

[LintCode/LeetCode] Minimum Path Sum

2016-04-17
阅读 1 分钟
2.4k
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.

[LintCode] Climbing Stairs

2016-04-17
阅读 1 分钟
1.8k
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

[LintCode] Remove Duplicates form Sorted List I & II

2016-04-17
阅读 2 分钟
2.1k
Given a sorted linked list, delete all duplicates such that each element appear only once.

[LintCode/LeetCode] Unique Paths II

2016-04-17
阅读 2 分钟
2k
Now consider if some obstacles are added to the grids. How many unique paths would there be?

[LintCode/LeetCode] Distinct Subsequences [一维DP]

2016-04-16
阅读 2 分钟
3.2k
Given a string S and a string T, count the number of distinct subsequences of T in S.

[LintCode] Minimum Adjustment Cost [Undone]

2016-04-16
阅读 2 分钟
2.7k
Given an integer array, adjust each integers so that the difference of every adjacent integers are not greater than a given number target.

[LintCode/LeetCode] Edit Distance

2016-04-16
阅读 2 分钟
1.9k
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.)

[LintCode/LeetCode] Unique Paths

2016-04-16
阅读 1 分钟
1.9k
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

[LintCode] Largest Rectangle in Histogram

2016-04-15
阅读 2 分钟
2.3k
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.

[LeetCode/LintCode] Word Ladder

2016-04-14
阅读 3 分钟
2.3k
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:

[LintCode/LeetCode] Jump Game I & II

2016-04-14
阅读 3 分钟
2.9k
Given an array of non-negative integers, you are initially positioned at the first index of the array.

[LeetCode/LintCode] Word Search

2016-04-13
阅读 2 分钟
2.1k
The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.

[LintCode/LeetCode] Longest Consecutive Sequence

2016-04-13
阅读 1 分钟
2.3k
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.