## 442. Find All Duplicates in an Array

Description:

https://leetcode.com/problems/find-all-duplicates-in-an-array/description/

Code:

Time & Space:
O(n) & O(1)

## 448. Find All Numbers Disappeared in an Array

Description:

https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/

Code:

Code for fastest algorithm:

Time & Space:
O(n) & O(1)

## 495. Teemo Attacking

Description:

https://leetcode.com/problems/teemo-attacking/description/

Code:

Time & Space:
O(n) & O(1)

## 532. K-diff Pairs in an Array

Description:

https://leetcode.com/problems/k-diff-pairs-in-an-array/description

Code:

Time & Space:
O(nlog(n)) & O(n)

## 485. Max Consecutive Ones

Description:

https://leetcode.com/problems/max-consecutive-ones/description/

Code:

Time & Space:
O(n) & O(1)

## 08/11/2017

3 BUFFERS in OpenGL Do MSAA in GLFW: http://blog.csdn.net/column/details/14890.html

http://blog.csdn.net/jxw167/article/details/56014355

## 628. Maximum Product of Three Numbers

Description:

https://leetcode.com/problems/maximum-product-of-three-numbers/description/

Code:

Time & Space:

O(n) & O(1)

Description:

Code:

Time & Space:
Record: O(1)
Sort: O(nlogn)
Calculate idle: O(1)

Space: O(1)

## 611. Valid Triangle Number

Description:

https://leetcode.com/problems/valid-triangle-number/description/

Algorithm1:

Use for loop for three times.

It works but slow (beats 23.60%)

Code1:

Timing & Space:

O(n^3) & O(1)

Algorithm2:

Code2:

Timing & Space:

Time:

Worst: O(n^2)

Best: O(1)

Space: O(1)

## 565. Array Nesting

Description:

https://leetcode.com/problems/array-nesting/description/

Algorithm:

Actually we are separating the array into several groups by determining S[k]. The numbers inside of S[k] will form a cycle.

For example:

Input: A = [5,4,0,3,1,6,2]

Output: 4

Explanation:

A = 5, A = 4, A = 0, A = 3, A = 1, A = 6, A = 2.

One of the longest S[K]:

S = {A, A, A, A} = {5, 6, 2, 0}

S = {A, A, A, A} = {6, 2, 0, 5}

S = {A, A, A, A} = {2, 0, 5, 6}

S = {A, A, A, A} = {0, 5, 6, 2}

S = {A, A} = {4,1}

S = {A, A} = {1,4}

S = {A} = {3}

So just mark the used number in the finding process. If meets used number -> stop.

Code:

Timing & Space:

fastest

O(n) & O(1)