[LintCode/CC] Update Bits [Merge Bits]

2016-03-28
阅读 2 分钟
1.7k
Given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e g , M becomes a substring of N located at i and starting at j)

[LintCode] Binary Representation

2016-03-28
阅读 3 分钟
1.8k
Given a (decimal - e.g. 3.72) number that is passed in as a string, return the binary representation that is passed in as a string. If the fractional part of the number can not be represented accurately in binary with at most 32 characters, return ERROR.

[LintCode] Flip Bits

2016-03-28
阅读 1 分钟
2.2k
Determine the number of bits required to flip if you want to convert integer n to integer m.

[LintCode] Delete Digits [Greedy]

2016-03-28
阅读 2 分钟
2.8k
Given string A representative a positive integer which has N digits, remove any k digits of the number, the remaining digits are arranged according to the original order to become a new positive integer.

[LintCode] Wood Cut

2016-03-27
阅读 2 分钟
2.4k
Given n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you could have equal or more than k pieces with the same length. What is the longest length you can get from the n pieces of wood? Given L & k, return the maximum length of the small pieces.

[LintCode/LeetCode] Largest Number [Comparator的使用]

2016-03-26
阅读 1 分钟
3.6k
Given a list of non negative integers, arrange them such that they form the largest number.

[LintCode] Matrix Zigzag Traversal

2016-03-26
阅读 1 分钟
2.3k
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in ZigZag-order.

[LintCode/LeetCode] Gas Station

2016-03-26
阅读 2 分钟
2.4k
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].

[LintCode/LeetCode] Maximum Product Subarray

2016-03-26
阅读 1 分钟
2.7k
Find the contiguous subarray within an array (containing at least one number) which has the largest product.

[LintCode] Permutation Index I & Permutation Index II

2016-03-25
阅读 3 分钟
4k
Given a permutation which contains no repeated number, find its index in all the permutations of these numbers, which are ordered in lexicographical order. The index begins at 1.

[LintCode] Segment Tree Modify

2016-03-25
阅读 2 分钟
1.9k
For a Maximum Segment Tree, which each node has an extra value max to store the maximum value in this node's interval.

[LintCode] Interval Minimum Number

2016-03-25
阅读 3 分钟
2.3k
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 index start and end in the given array, return the result list.

[LintCode] Interval Sum

2016-03-25
阅读 2 分钟
2.8k
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 sum number between index start and end in the given array, return the result list.

[LintCode/LeetCode] Perfect Squares

2016-03-25
阅读 2 分钟
3.1k
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.

[LeetCode] 69. Sqrt(x)

2016-03-24
阅读 2 分钟
2.8k
Compute and return the square root of x, where x is guaranteed to be a non-negative integer.

[LintCode/LeetCode] Wiggle Sort I & Wiggle Sort II

2016-03-24
阅读 2 分钟
5.1k
Given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4].

[LintCode] Segment Tree Query I & Segment Tree Query II

2016-03-24
阅读 3 分钟
2.5k
For an integer array (index from 0 to n-1, where n is the size of this array), in the corresponding SegmentTree, each node stores an extra attribute max to denote the maximum number in the interval of the array (index from start to end).

[LintCode/LeetCode] Paint House I & Paint House II

2016-03-23
阅读 3 分钟
3.4k
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 certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

[LeetCode] 276. Paint Fence

2016-03-23
阅读 1 分钟
3.4k
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 fence posts have the same color.Return the total number of ways you can paint the fence.

[LintCode/LeetCode] Super Ugly Number

2016-03-23
阅读 2 分钟
3k
Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13, 14, 16, 19, 26, 28, 32] is the sequence of the first 12 super ugly numbers given primes = [2, 7, 13, 19] of size 4.

[LintCode] Ugly Number

2016-03-21
阅读 1 分钟
2k
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7.

[LintCode] Find the Missing Number [三种方法]

2016-03-16
阅读 2 分钟
5.3k
Given an array contains N numbers of 0 .. N, find which number doesn't exist in the array.

[LintCode] First Missing Positive

2016-03-16
阅读 2 分钟
1.9k
Given an unsorted integer array, find the first missing positive integer.

[LintCode/LeetCode] Intersection of Two Linked Lists

2016-03-13
阅读 1 分钟
2k
Write a program to find the node at which the intersection of two singly linked lists begins.

[LintCode/LeetCode] Trapping Rain Water [栈和双指针]

2016-03-13
阅读 4 分钟
5.1k
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.

[LintCode] Spiral Matrix I & Spiral Matrix II

2016-03-13
阅读 3 分钟
3k
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.

[LintCode] Permutation Sequence

2016-03-12
阅读 2 分钟
2.5k
"123""132""213""231""312""321"If k = 4, the fourth permutation is "231".

[LintCode] Valid Sudoku [数独]

2016-03-12
阅读 2 分钟
2.7k
The Sudoku board could be partially filled, where empty cells are filled with the character '.'.

[LintCode] The Smallest Difference

2016-03-12
阅读 1 分钟
2.5k
Given two array of integers(the first array is array A, the second array is array B), now we are going to find a element in array A which is A[i], and another element in array B which is B[j], so that the difference between A[i] and B[j] (|A[i] - B[j]|) is as small as possible, return their small...

[LintCode] Longest Substring Without Repeating Characters

2016-03-10
阅读 3 分钟
2.1k
Given a string, find the length of the longest substring without repeating characters.