The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of …
分类:LeetCode题目解答汇总
LeetCode | Unique Paths(唯一路径)
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in t…
LeetCode | Sqrt(x)
Implement int sqrt(int x). 题目解析: 求开方根,只是求解整数,比较容易,如果求解double类型的,就要考虑精度问题。 题型一:求整数根 先讲解求解整数根的情况。 题目简单,可以直接…
LeetCode | Edit Distance(字符串编辑距离)
Given two words word1 and word2, find the minimum number of steps required to convert word…
LeetCode | Climbing Stairs(爬楼梯)
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb …
LeetCode | Set Matrix Zeroes(矩阵相应行列清零)
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in pla…
LeetCode | Sort Colors(荷兰国旗问题)
Given an array with n objects colored red, white or blue, sort them so that objects of the same colo…
LeetCode | Search a 2D Matrix(二维矩阵中查找)
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has…
LeetCode | Combinations(n选k全排列)
Given two integers n and k, return all possible combinations of k numbers out of 1 …
LeetCode | Remove Duplicates from Sorted Array II(删除重复的元素2)
Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? For example,…
LeetCode | Subsets(子集)
Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in n…
LeetCode | Remove Duplicates from Sorted List(删除链表中重复的数据)
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, G…