leetcode59.Spiral Matrix II
题目要求
1 | Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. |
也就是将递加的数字按照顺时针的顺序依次填入数组之中
这道题目联系到Spiral Matrix I,其实就相当好解决了。Spiral Matrix I可以参考我的这篇博客
leetcode57.Insert Interval
题目要求
1 | Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). |
给定一组顺序排列且相互之间没有重叠的区间,输入一个区间,将它插入到当前的区间数组中,并且将需要合并的区间合并,之后返回插入并且合并后的区间。
leetcode62.Unique Paths
题目要求
1 | A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). |
1 | Above is a 3 x 7 grid. How many possible unique paths are there? |
一个机器人站在下标为(1,1)的起点走向下标为(m,n)的终点。机器人只允许往下走和往右走。问一共有多少条独特的路线?
leetcode43.Multiply Strings
题目要求
1 | Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2. |
将两个String形式的数字相乘的结果用String的形式返回。不准使用Int(java)以外的形式来记录数字。
leetcode81.Search in Rotated Sorted Array II
题目要求
1 | Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. |
相比于I,II中添加了数组中可能存在重复值的条件。大家可以先参考一下我的这篇关于I的博客,在这个基础上,考虑如何实现这道题目。
leetcode63.Unique Paths II
题目要求
1 | Follow up for "Unique Paths": |
这是Unique Path题目系列。关于Unique Path I请参考我的这篇博客。相比于I,这里添加的需求是说,某些节点上存在路障。存在路障的节点会在数组中被标记为1。请问从起点到终点有多少条独立路径。
leetcode64.Minimum Path Sum
题目要求
1 | Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. |
计算从左上角到右下角的最短路径长度。只能向下或者向右移动。
类似的题目请参考我的博客Unique Path I 和 Unique Path II
leetcode82.Remove Duplicates from Sorted List II
题目要求
1 | Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. |
将链表中重复的元素全部删除,返回新的头结点。
相比于Remove Duplicates from Sorted List I,这里将重复的元素全部删除。
想要了解Remove Duplicates from Sorted List I,请参考我的这篇博客
leetcode60.Permutation Sequence
题目要求
The set [1,2,3,…,n] contains a total of n! unique permutations.
By listing and labeling all of the permutations in order,
We get the following sequence (ie, for n = 3):
1."123"
2."132"
3."213"
4."231"
5."312"
6."321"
Given n and k, return the kth permutation sequence.
Note: Given n will be between 1 and 9 inclusive.
假设按照题中给的排列组合的顺序,假设有1~n个数字,返回第k个排列组合的结果。