关闭

Leetcode 55. Jump Game

题目 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine i...
阅读(339) 评论(0)

658. Find K Closest Elements

Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always prefer...
阅读(368) 评论(0)

138. Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.code注意某个节点没有next,但是有random的情况/* * Defi...
阅读(171) 评论(0)

133. Clone Graph

Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ’s undirected graph serialization: Nodes are labeled uniquely.We use # as a separator for each node, an...
阅读(270) 评论(0)

61. Rotate List

在指定位置旋转链表...
阅读(120) 评论(0)

240. Search a 2D Matrix II

题目深度和宽度方向都是递增序列的二维数组,查看目标值是否存在。 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from le...
阅读(105) 评论(0)

74. Search a 2D Matrix

分别在深度方向和宽度方向二查搜索。题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first int...
阅读(166) 评论(0)

80. Remove Duplicates from Sorted Array II

题目可以重复一次的去重操作Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first...
阅读(248) 评论(0)

59. Spiral Matrix II

题目生成螺旋矩阵 Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example, Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ],...
阅读(301) 评论(0)

54. Spiral Matrix

螺旋式遍历矩阵 如下图所示的方法。 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7,...
阅读(379) 评论(0)

90. Subsets II

题目Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,2], a solution i...
阅读(319) 评论(0)

78. Subsets

题目Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,3], a solution is:[ [3], [1], [2], [...
阅读(239) 评论(0)

60. Permutation Sequence

题目求n个排序数的第k项 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):"123" "132" "213" "...
阅读(278) 评论(0)

147. Sort a linked list using insertion sort

题目Sort a linked list using insertion sort.代码public ListNode InsertionSortList(ListNode head) { if (head == null) return null; //begining point of the sorted list, set a...
阅读(241) 评论(0)

142. Linked List Cycle II

题目Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using extra space?代码/** * Defi...
阅读(286) 评论(0)

41. First Missing Positive

Find Missing Number 系列问题,灵活运用index,或异或在O(n)时间复杂度,O(1)空间复杂度解决问题。题目Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3, and [3,4,-1,1] return 2. Y...
阅读(152) 评论(0)

47. Permutations II

原题求解带有重复元素的序列的所有排序 Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations:[ [1,1,2], [1,2...
阅读(183) 评论(0)

46. Permutations

求一个序列的所有排序组合。题目Given a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],...
阅读(167) 评论(0)

31. Next Permutation

求其下一个排序数的思路: 1. **逆序**搜索,找到第一个满足 $$nums[i-1]=1子序列的最小值。 最小值为 **4**;即交换 3 和 4,得到的序列为:**4** 5 **3** 2 1 3. 将i>=1的序列反转,即 4 **1 2 3 5**...
阅读(157) 评论(0)

64. Minimum Path Sum

题目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.Note: You can only move either down or right at an...
阅读(232) 评论(0)
207条 共11页1 2 3 4 5 ... 下一页 尾页
    Leetcode Solutions in Github

    Click me

    Leetcode solutions in Github, including tags: Array, HashTable, Stack, Queue, LinkedList, Tree, Graph,...

    leetcode-manager

    Click me

    Current Leetcode manager: it's used by Entity Framework, WinForms, Sql Server to manage leetcode questions that we have done. Functions include tags creation, revise and deletion, and questions creation, edit and deletion.

    个人资料
    • 访问:126188次
    • 积分:5037
    • 等级:
    • 排名:第5927名
    • 原创:311篇
    • 转载:0篇
    • 译文:0篇
    • 评论:53条
    博客专栏