[LintCode] Simplify Path [字符串操作]

2016-02-18
阅读 2 分钟
2.2k
Another corner case is the path might contain multiple slashes '/' together, such as "/home//foo/".

[LintCode] Evaluate Reverse Polish Notation

2016-02-17
阅读 2 分钟
1.8k
Evaluate the value of an arithmetic expression in Reverse Polish Notation.

[LintCode] Nuts & Bolts Problem

2016-02-17
阅读 3 分钟
2.9k
Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping between nuts and bolts. Comparison of a nut to another nut or a bolt to another bolt is not allowed. It means nut can only be compared with bolt and bolt can only be compared with nut to see which ...

[LintCode/LeetCode] Maximal Square

2016-02-16
阅读 1 分钟
2.1k
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.

[LintCode] Max Points on a Line

2016-02-16
阅读 2 分钟
2.3k
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

[LintCode] Segment Tree Build & Segment Tree Build II

2016-02-15
阅读 3 分钟
2.3k
The structure of Segment Tree is a binary tree which each node has two attributes start and end denote an segment / interval.

[LeetCode] Permutations I / II

2016-02-13
阅读 3 分钟
2.3k
Permutations I Problem Given a list of numbers, return all possible permutations. Example For nums = [1,2,3], the permutations are: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]] Challenge Do it without recursion. Solution Recursion {代码...} Permutations II Problem Given a collection of...

[LintCode] First Position of Target

2016-02-12
阅读 2 分钟
3.1k
For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity.

[LintCode] strStr [KMP & brute force]

2016-02-11
阅读 2 分钟
3.5k
For a given source string and a target string, you should output the first index(from 0) of target string in source string.

[LintCode/LeetCode] Min Stack/Max Stack

2016-02-11
阅读 3 分钟
4.6k
Implement a stack with min() function, which will return the smallest number in the stack.

[LintCode] Search Range in Binary Search Tree

2016-02-11
阅读 1 分钟
2.3k
Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all x such that k1<=x<=k2 and x is a key of given BST. Return all the keys in ascending order.

[LintCode] Fizz Buzz

2016-02-11
阅读 1 分钟
2.4k
when number is divided by 3, print "fizz".when number is divided by 5, print "buzz".when number is divided by both 3 and 5, print "fizz buzz".

[LintCode] Rotate String [周而复始]

2016-02-11
阅读 2 分钟
3.5k
Given a string and an offset, rotate string by offset. (rotate from left to right)

[LintCode/LeetCode] Binary Tree Serialization

2016-02-10
阅读 5 分钟
3.1k
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back from the file to reconstruct the exact same binary tree is 'deserialization'.

[LintCode] Merge Sorted Array II

2016-02-10
阅读 2 分钟
2.1k
Merge two given sorted integer array A and B into a new sorted integer array.

[LintCode] Kth Largest Element [PriorityQueue]

2016-02-10
阅读 2 分钟
2.9k
In array [9,3,2,4,8], the 3rd largest element is 4.In array [1,2,3,4,5], the 1st largest element is 5, 2nd largest element is 4, 3rd largest element is 3 and etc.

[LintCode] Ugly Number

2016-02-10
阅读 2 分钟
2k
Ugly number is a number that only have factors 3, 5 and 7.Design an algorithm to find the Kth ugly number. The first 5 ugly numbers are 3, 5, 7, 9, 15 ...

[LintCode] Digit Counts

2016-02-06
阅读 2 分钟
2.4k
if n=12, k=1 in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], we have FIVE 1's (1, 10, 11, 12)

[LeetCode/LintCode] Factorial Trailing Zeros

2016-02-06
阅读 1 分钟
2.6k
Write an algorithm which computes the number of trailing zeros in n factorial.

[LintCode] A + B Problem(位运算)

2016-02-06
阅读 1 分钟
4.1k
Write a function that add two numbers A and B. You should not use + or any arithmetic operators.

[LintCode/LeetCode] Restore IP Addresses

2016-02-06
阅读 4 分钟
2.2k
Given a string containing only digits, restore it by returning all possible valid IP address combinations.

[LintCode] Cosine Similarity

2016-02-06
阅读 1 分钟
2.7k
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 cosine of 0° is 1, and it is less than 1 for any other angle.See wiki: Cosine SimilarityHere is the formula:Given two vectors A and B with the same si...

[LintCode] Reverse Nodes in k-Group

2016-02-06
阅读 2 分钟
2.2k
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

[LintCode/LeetCode] Letter Combinations of a Phone Number

2016-02-05
阅读 3 分钟
2.7k
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.

[LintCode/LeetCode] Flatten Binary Tree to Linked List

2016-02-05
阅读 2 分钟
2.8k
Flatten a binary tree to a fake "linked list" in pre-order traversal.Here we use the right pointer in TreeNode as the next pointer in ListNode.

[LintCode] Palindrome Linked List

2016-02-05
阅读 1 分钟
2.3k
Problem Implement a function to check if a linked list is a palindrome. Example Given 1->2->1, return true. Key create new list nodes: {代码...} Solution {代码...}

[LintCode] Swap Nodes in Pairs

2016-02-03
阅读 2 分钟
2.3k
Given a linked list, swap every two adjacent nodes and return its head.

[LintCode] Remove Linked List Elements

2016-02-03
阅读 1 分钟
2.5k
Remove all elements from a linked list of integers that have value val.

[LintCode] Palindrome Partitioning

2016-02-03
阅读 2 分钟
2.3k
Given a string s, partition s such that every substring of the partition is a palindrome.

[LintCode/LeetCode] Add and Search Word

2016-02-02
阅读 2 分钟
2.6k
Design a data structure that supports the following two operations: addWord(word) and search(word)