- 博客(46)
- 收藏
- 关注
原创 【LeetCode】37. Reorder List
题目描述(Medium)Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…题目链接https://leetcode.com/problems/reorder-list/description/Example 1:Given 1->2->3->...
2018-08-31 16:45:30 104
原创 【LeetCode】36. Linked List Cycle II
题目描述(Medium)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 spa...
2018-08-31 15:29:49 92
原创 【LeetCode】35. Linked List Cycle
题目描述(Easy)Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?题目链接https://leetcode.com/problems/linked-list-cycle/description/算法分析...
2018-08-31 14:48:09 82
原创 【LeetCode】34. Copy List with Random Pointer
题目描述(Medium)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.题目链接https://leetco...
2018-08-30 18:32:47 84
原创 【LeetCode】33. Reverse Nodes in k-Group
题目描述(Hard)Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If th...
2018-08-30 16:21:28 92
原创 【LeetCode】32. Swap Nodes in Pairs
题目描述(Medium)Given a linked list, swap every two adjacent nodes and return its head.题目链接https://leetcode.com/problems/swap-nodes-in-pairs/description/Example 1:Given 1->2->3->4, you...
2018-08-30 13:08:26 168
原创 【LeetCode】31. Remove Nth Node From End of List
题目描述(Medium)Given a linked list, remove the n-th node from the end of list and return its head.题目链接https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/Example 1:Given...
2018-08-29 16:38:44 70
原创 【LeetCode】30. Rotate List
题目描述(Medium)Given a linked list, rotate the list to the right by k places, where k is non-negative.题目链接https://leetcode.com/problems/rotate-list/description/Example 1:Input: 1->2->3-&...
2018-08-29 15:57:46 107
原创 【LeetCode】29.Remove Duplicates from Sorted List II
题目描述(Medium)Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.题目链接https://leetcode.com/problems/remove-duplicates-fro...
2018-08-29 15:17:16 102
原创 【LeetCode】28.Remove Duplicates from Sorted List
题目描述(Easy)Given a sorted linked list, delete all duplicates such that each element appear only once.题目链接https://leetcode.com/problems/remove-duplicates-from-sorted-list/description/Example 1:...
2018-08-29 13:40:59 84
原创 【LeetCode】27.Partition List
题目描述(Medium)Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the node...
2018-08-29 13:09:56 99
原创 【LeetCode】26.Reverse Linked List II
题目描述(Medium)Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.题目链接https://leetcode.com/problems/reverse-linked-list-ii/description/Example 1:I...
2018-08-29 12:27:03 111
原创 【LeetCode】25.Add Two Numbers
题目描述(Medium)You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two number...
2018-08-28 15:44:37 128
原创 【LeetCode】24.Single Number II
题目描述(Medium)Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runti...
2018-08-28 13:28:55 84
原创 【LeetCode】23.Single Number
题目描述(Easy)Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement i...
2018-08-28 10:54:23 89
原创 【LeetCode】22.Candy
题目描述(Hard)There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at ...
2018-08-28 10:29:39 113
原创 【LeetCode】21.Gas Station
题目描述(Medium)There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from sta...
2018-08-27 19:59:29 108
原创 【LeetCode】20.Set Matrix Zeroes
题目描述(Medium)Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.题目链接https://leetcode.com/problems/set-matrix-zeroes/description/Example 1:Input:[ ...
2018-08-27 17:34:12 73
原创 【LeetCode】19.Gray Code
题目描述(Medium)The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the ...
2018-08-27 16:27:22 239
原创 【LeetCode】18.Climbing Stairs
题目描述(Easy)You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will b...
2018-08-25 15:44:29 74
原创 【LeetCode】17.Plus One
题目描述(Easy)Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and ...
2018-08-25 15:34:14 116
原创 【LeetCode】16.Rotate Image
题目描述(Medium)You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the inp...
2018-08-25 15:18:25 102
原创 【LeetCode】15.Trapping Rain Water
题目描述(Hard)Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above elevation map is represen...
2018-08-25 14:22:33 99
原创 【LeetCode】14.Valid Sudoku
题目描述(Medium)Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition. Each col...
2018-08-24 18:50:16 104
原创 【LeetCode】13.Permutation Sequence
题目描述(Medium)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 for n = 3:"123""132""213""...
2018-08-24 16:23:39 113
原创 【LeetCode】12.Next Permutation
题目描述(Medium)Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowe...
2018-08-24 14:07:34 112
原创 【LeetCode】11.Remove Element
题目描述(Easy)Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the...
2018-08-23 17:07:27 94
原创 【LeetCode】10.4Sum
题目描述(Medium)Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives ...
2018-08-23 16:42:05 100
原创 【LeetCode】9.3Sum Closest
题目描述(Medium)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 eac...
2018-08-22 16:30:23 124
原创 【LeetCode】8.3Sum
题目描述(Medium)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 mu...
2018-08-22 15:57:16 91
原创 【LeetCode】7.Two Sum
题目描述(Easy)Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use...
2018-08-22 14:27:42 73
原创 【LeetCode】6.Longest Consecutive Sequence
题目描述(Hard)Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.题目链接https://leetcode.com/problems/median-...
2018-08-21 17:29:20 105
原创 【LeetCode】5.Median of Two Sorted Arrays
题目描述(Hard)There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume num...
2018-08-21 16:11:19 99
原创 【LeetCode】4.Search in Rotated Sorted Array II
题目描述(Medium)Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).You are given a target value to searc...
2018-08-10 16:17:27 89
原创 【LeetCode】3.Search in Rotated Sorted Array
题目描述(Medium)Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to searc...
2018-08-10 15:28:56 88
原创 【LeetCode】2.Remove Duplicates from Sorted Array II
题目描述(Medium)Given a sorted array nums, remove the duplicates in - place such that duplicates appeared at most twice and return the new length. Do not allocate extra space for another array, you must...
2018-08-10 10:47:19 97
原创 【LeetCode】1.Remove Duplicates from Sorted Array
题目描述(Easy)Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this...
2018-08-08 15:42:38 100
原创 【剑指】70.涉及自定义类
ListNode.h:#pragma oncestruct ListNode{ int val; ListNode* next; ListNode(int value) : val(value), next(nullptr) {} ListNode() {}};ListNode* CreateListNode(int value);void Conn...
2018-08-08 14:07:31 138
原创 【剑指】69.矩阵覆盖
题目描述我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?算法分析斐波那契数列问题,f(1) = 1, f(2) = 2, f(3) = f(1) + f(2), ..., f(n) = f(n-2) + f(n-1), ...提交代码:class Solution {public: i...
2018-08-08 14:02:07 106
原创 【剑指】68.树中两个结点的最低公共祖先
题目描述输入两个二叉树结点,求它们的最低公共祖先。算法分析用两个链表分别保存从根节点到输入的两个节点的路径,然后把问题转换成两个链表的最后公共节点。提交代码:class Solution {public: const TreeNode* getLastCommonParent(const TreeNode* pRoot, const TreeNode* pN...
2018-08-08 13:36:10 84
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人