LeetCode(309)-Best Time to Buy and Sell Stock with Cooldown/最佳买卖股票的时间(动态规划)

题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may c...

2019-05-29 15:10:31

阅读数 40

评论数 0

LeetCode(283)-Move Zeroes/移除0

题目: Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Example: In...

2019-05-28 20:44:32

阅读数 20

评论数 0

LeetCode(239)-Sliding Window Maximum/返回滑动窗口最大值(双端队列)

题目: Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the ...

2019-05-28 19:02:26

阅读数 45

评论数 0

LeetCode(238)-Product of Array Except Self/数组除自身外的乘积(O(n))

题目: Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of ...

2019-05-28 16:02:48

阅读数 19

评论数 0

LeetCode(234)-Palindrome Linked List/反转链表(快慢指针+反转链表)

题目: Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2-...

2019-05-28 14:45:23

阅读数 27

评论数 0

LeetCode(221)-Maximal Square/二维矩阵最大正方形面积(O(N^2)动态规划)

题目: Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. Example: Input: 1 0 1 0 0 1 0 ...

2019-05-28 13:11:51

阅读数 51

评论数 0

LeetCode(215)- Kth Largest Element in an Array/第k大数(堆排/快排)

题目: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Exa...

2019-05-27 21:37:01

阅读数 30

评论数 0

LeetCode(206)-Reverse Linked List/反转链表

题目: Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2-&...

2019-05-27 18:28:18

阅读数 21

评论数 0

LeetCode(200)-Number of Islands/寻找陆地(深度优先搜索算法)

题目: Given a 2d grid map of '1’s (land) and '0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting ad...

2019-05-27 18:00:04

阅读数 69

评论数 0

LeetCode(198)-House Robber/找出数组中不相邻元素最大和(动态规划)

题目: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stoppi...

2019-05-27 16:50:11

阅读数 31

评论数 0

LeetCode(169)-Majority Element/找到数组中多数(O(n))

题目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume tha...

2019-05-27 12:17:51

阅读数 34

评论数 0

LeetCode(160)-Intersection of Two Linked Lists(判断两条链表是否相交-两种解法)

题目: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin...

2019-05-27 11:42:57

阅读数 31

评论数 0

LeetCode(155)-Min Stack(最小栈-三种解法)

题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Re...

2019-05-27 11:06:13

阅读数 32

评论数 0

LeetCode(152)-Maximum Product Subarray(连续子数组最大乘积)

题目: Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example...

2019-05-27 09:41:51

阅读数 25

评论数 0

LeetCode(148)- Sort LIst(链表排序)

题目: Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2-&...

2019-05-26 20:44:48

阅读数 23

评论数 0

LeetCode(142)- Linked List Cycle II(找到有环链表环入口)

题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we...

2019-05-26 19:18:05

阅读数 29

评论数 0

LeetCode(141)-Linked List Cycle(判断一个链表是否有环)

题目: Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the...

2019-05-26 18:37:25

阅读数 30

评论数 0

LeetCode(139)-Word Break(断字/动态规划)

题目: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated...

2019-05-25 16:15:13

阅读数 29

评论数 0

LeetCode(136)-Single Number(单数/异或实现)

题目: 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 ...

2019-05-24 17:08:08

阅读数 25

评论数 0

LeetCode(128)-Longest Consecutive Sequence(最长连续序列)

题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. ...

2019-05-24 16:51:46

阅读数 25

评论数 0

提示
确定要删除当前文章?
取消 删除