# Array - 59. Spiral Matrix II

Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.

# Array - 54. Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.

# Array - 48. Rotate Image

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise).

# Array - 34. Find First and Last Position of Element in Sorted Array

Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.

# Array - 31. Next Permutation

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

# Array - 16. 3Sum Closest

16. 3Sum Closest Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example: Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). 思路： 给定一个数组，找出三个数的和最接近target，和15题很像，做法类似，都是对于每一位元素，用双指针找出另外两个数，更新出一个最小的结果就可以。 代码： go： f....

# Array - 15. 3Sum

15. 3Sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1, 0, 1], [-1, -1, 2] ] 思路： 找出数组中三数和的所有组合，解决思路是首先做一个排序，然后对于每一位元素，去找出剩下数组中找出两个数和当前元素三个数和为0就可以，主要要留意重复元素就不用了计算....

Nothing just happens, it's all part of a plan.