leetcode
lirt15
这个作者很懒,什么都没留下…
展开
-
leetcode_300 Longest Increasing Subsequence(贪心+二分查找)
Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101]...原创 2020-05-08 00:30:49 · 210 阅读 · 1 评论 -
leetcode_206 Reverse Linked List
问题描述Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULL思路分析有递归和非递归两种方法,递归算法可以去掉头结点然后反转子链表,然后把头结点插入到末尾;...原创 2019-08-13 12:29:47 · 90 阅读 · 0 评论 -
leetcode_209 Minimum Size Subarray Sum
题目描述Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.Example:Input: s = 7,...原创 2019-08-18 19:40:12 · 143 阅读 · 0 评论 -
leetcode_207 Course Schedule (dfs, bfs, 拓扑排序)
class Solution: def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool: pre_dict = [[] for _ in range(numCourses)] tested = [0 for _ in range(numCourses)]...原创 2019-08-14 16:11:14 · 177 阅读 · 0 评论 -
leetcode_201 Bitwise AND of Numbers Range
问题描述Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.Example 1:Input: [5,7]Output: 4Example 2:Input: [0,1]Output: 0...原创 2019-08-11 21:42:14 · 98 阅读 · 0 评论 -
leetcode_208 Implement Trie (Prefix Tree)
题目描述Implement a trie with insert, search, and startsWith methods.Example:Trie trie = new Trie();trie.insert("apple");trie.search("apple"); // returns truetrie.search("app"); // returns fa...原创 2019-08-16 00:20:17 · 153 阅读 · 0 评论 -
leetcode_202 Happy Number
Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of...原创 2019-08-12 15:51:20 · 106 阅读 · 0 评论 -
leetcode_203 Remove Linked List Elements
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def removeElements(self, head: ListNode, val:...原创 2019-08-12 19:52:18 · 100 阅读 · 0 评论