[LintCode] Substring Anagrams

2017-12-29
阅读 2 分钟
1.4k
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.

[LintCode] Add Two Numbers II

2017-12-19
阅读 2 分钟
1.4k
You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in forward order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list.

[LintCode] Big Integer Addition

2017-12-18
阅读 2 分钟
1.9k
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.

[LintCode] Max Tree

2016-11-14
阅读 2 分钟
3.6k
Given an integer array with no duplicates. A max tree building on this array is defined as follow:

AO Rettiwt

2016-11-12
阅读 7 分钟
2.6k
Kraken is m*n grids on a rectangular board. From the top left to reach the bottom right corner while moving one grid at a time in either the down, right or down-right diagonal directions

【系统设计】Design Netflix & Design User System & Design Rate Limiter

2016-11-06
阅读 6 分钟
5.2k
System Design Concept — Logic — Implementation {代码...} Design Netflix SNAKE Analysis 1. Scenario: 枚举&排序 {代码...} 2. Needs/Necessary: 限制 {代码...} 3. Application/Kilobyte 重访&组合/添加&选择 {代码...} 4. Evolve 分析&回溯 {代码...} Design Recommendation Module: {代码...} De...

[LeetCode] Additive Number

2016-10-26
阅读 2 分钟
2.4k
A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two.

y-a-b-e

2016-10-20
阅读 28 分钟
2.6k
算法 链表 【LC总结】翻转链表 Swap in Pairs, Reverse in k-Group, Reverse LinkedList###Reverse a doubly linkedlist reverse singly linked list Iteration: {代码...} Recursion: {代码...} 二叉树 Subtree {代码...} Binary Tree Level Order Traversal If is required bottom-up, use Collections.reverse(res); ...

【LC总结】翻转链表 Swap in Pairs, Reverse in k-Group, Reverse LinkedList

2016-10-20
阅读 3 分钟
2.5k
For example,Given 1->2->3->4, you should return the list as 2->1->4->3.

[LeetCode] Reverse Linked List I & II

2016-10-20
阅读 2 分钟
2.1k
Head loop through the list: Store head.next, head points to tail, tail becomes head, head goes to stored head.next;

[LeetCode] Largest BST Subtree

2016-10-20
阅读 2 分钟
3.4k
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.

[LeetCode] Design Phone Directory

2016-10-18
阅读 2 分钟
3k
get: Provide a number which is not assigned to anyone.check: Check if a number is available or not.release: Recycle or release a number.

Hackerrank Practice

2016-10-17
阅读 22 分钟
7.5k
输入第一行是要判断的字符串的个数n,之后的n行输入为需要判断的字符串。每个字符串str,是两个等长字符串的合体,所以长度一定是偶数。若为奇数,返回-1。所以str分成两个substring,右边需要多少次操作能变为左边。只要用一个26位的数组统计每个字符在a和b中出现的次数就行,在a中出现+1,在b中出现-1,最后统计数组的...

[LeetCode] Top K Frequent Elements [HashMap/Heap/TreeMap]

2016-10-12
阅读 4 分钟
5.1k
Given a non-empty array of integers, return the k most frequent elements.

【LC总结】图、拓扑排序 (Course Schedule I, II/Alien Dictionary待做)

2016-10-07
阅读 5 分钟
2.8k
There are a total of n courses you have to take, labeled from 0 to n - 1.

【LC总结】回溯 (Subsets I II/Permutation I II/Combination Sum I II)

2016-10-04
阅读 7 分钟
2.6k
Given a collection of integers that might contain duplicates, nums, return all possible subsets.

[LeetCode] Count Primes

2016-10-02
阅读 2 分钟
2.3k
Problem Count the number of prime numbers less than a non-negative number, n. Note 用数组flag标记非质数,每当出现一个flag[i]为false,计数器count加一。关于质数有三点: 大于3的质数一定是奇数,如3,5,7; 奇数中的非质数也一定是奇数的乘积。 对于一个很大的数n,它的两个因数i和j中一定有一个小于n的开方,...

[LeetCode] Rotate Function

2016-09-30
阅读 2 分钟
2.5k
Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow:

【LC总结】KMP * Implement Strstr

2016-09-30
阅读 1 分钟
1.9k
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

【LC总结】Union Find系列(Num of Islands I&II/Graph Valid Tree/etc)

2016-09-26
阅读 5 分钟
4.3k
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.

【LC总结】K Sum (Two Sum I II/3Sum/4Sum/3Sum Closest)

2016-09-23
阅读 7 分钟
3.4k
Given an array of integers, find two numbers such that they add up to a specific target number.

【LC总结】Intervals题目 (Insert/Merge/Number of Airplanes)

2016-09-22
阅读 4 分钟
3.4k
Merge Intervals Problem Given a collection of intervals, merge all overlapping intervals. Example Given intervals => merged intervals: {代码...} Challenge O(n log n) time and O(1) extra space. Note 忘了这题怎么做,汗颜无地。 边界: size < 2 sort by Comparator<Interval> loop: merge &amp...

[LintCode] Build Post Office I & II

2016-09-22
阅读 6 分钟
5.6k
Given a 2D grid, each cell is either an house 1 or empty 0 (the number zero, one), find the place to build a post office, the distance that post office to all the house sum is smallest. Return the smallest distance. Return -1 if it is not possible.

[LeetCode] Integer Replacement

2016-09-17
阅读 1 分钟
2.9k
If n is even, replace n with n/2.If n is odd, you can replace n with either n + 1 or n - 1.What is the minimum number of replacements needed for n to become 1?

【LC总结】Iterator题目<Zigzag 1&2><BST><FlattenNested><Peeking>

2016-09-17
阅读 7 分钟
2.8k
Given two 1d vectors, implement an iterator to return their elements alternately.

[LintCode] Swap Two Nodes in Linked List

2016-09-15
阅读 2 分钟
2.3k
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 values in the linked list. If v1 or v2 does not exist in the given linked list, do nothing.

[LintCode/LeetCode] Find Median From / Data Stream Median

2016-08-30
阅读 3 分钟
2.3k
Numbers keep coming, return the median of numbers at every time a new number added.

[LintCode/LeetCode] Sliding Window Maximum/Median

2016-08-29
阅读 2 分钟
3.1k
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.

[LC] Perfect Rectangle / Find the Difference / Elimination Game

2016-08-28
阅读 4 分钟
3.1k
User Accepted: 812User Tried: 861Total Accepted: 1362Total Submissions: 1552Difficulty: Easy

[Interview] Pass-by-value vs. Pass-by Reference

2016-08-24
阅读 2 分钟
1.6k
Pass by value: make a copy in memory of the actual parameter's value that is passed in.