随笔分类 -  LeetCode

摘要:题目: Design a data structure that supports all following operations in averageO(1) time. insert(val): Inserts an item val to the set if not already pre 阅读全文
posted @ 2020-01-31 14:33 silentteller 阅读(261) 评论(0) 推荐(0)
摘要:题目: Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Input: [1,3,5,4,7] Output: 2 Explanation: The t 阅读全文
posted @ 2020-01-17 17:54 silentteller 阅读(186) 评论(0) 推荐(0)
摘要:题目: You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-negative 2D map, in this map: 0 represents the obs 阅读全文
posted @ 2020-01-17 15:51 silentteller 阅读(320) 评论(0) 推荐(0)
摘要:题目: Design and implement a data structure for Least Frequently Used (LFU)cache. It should support the following operations: get and put. get(key) - Ge 阅读全文
posted @ 2020-01-15 16:02 silentteller 阅读(383) 评论(0) 推荐(0)
摘要:题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears 阅读全文
posted @ 2020-01-12 00:48 silentteller 阅读(364) 评论(0) 推荐(0)
摘要:题目: Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the 阅读全文
posted @ 2020-01-08 16:35 silentteller 阅读(475) 评论(0) 推荐(0)
摘要:题目: Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the 阅读全文
posted @ 2020-01-06 15:10 silentteller 阅读(236) 评论(0) 推荐(0)
摘要:题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get 阅读全文
posted @ 2020-01-06 00:24 silentteller 阅读(728) 评论(0) 推荐(0)
摘要:题目: Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be given a list of non-repetitive words to build 阅读全文
posted @ 2019-10-20 19:47 silentteller 阅读(295) 评论(0) 推荐(0)
摘要:题目: Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination, 阅读全文
posted @ 2019-10-20 18:49 silentteller 阅读(330) 评论(0) 推荐(0)
摘要:题目: Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Example 2: Note: Length o 阅读全文
posted @ 2019-10-14 23:11 silentteller 阅读(224) 评论(0) 推荐(0)
摘要:题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at a 阅读全文
posted @ 2019-10-11 22:15 silentteller 阅读(333) 评论(0) 推荐(0)
摘要:题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at a 阅读全文
posted @ 2019-10-11 20:25 silentteller 阅读(257) 评论(0) 推荐(0)
摘要:题目: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Example 2: Note:Y 阅读全文
posted @ 2019-10-11 19:19 silentteller 阅读(270) 评论(0) 推荐(0)
摘要:题目: Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we 阅读全文
posted @ 2019-09-11 16:48 silentteller 阅读(387) 评论(0) 推荐(0)
摘要:题目: Count the number of prime numbers less than a non-negative number, n. Example: 分析: 统计所有小于非负整数 n 的质数的数量。 这里使用埃拉托斯特尼筛法。要得到自然数n以内的全部素数,必须把不大于√n的所有素数的 阅读全文
posted @ 2019-09-11 16:05 silentteller 阅读(434) 评论(0) 推荐(0)
摘要:题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return 阅读全文
posted @ 2019-07-11 20:07 silentteller 阅读(850) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return the postorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it itera 阅读全文
posted @ 2019-07-11 18:33 silentteller 阅读(281) 评论(0) 推荐(0)
摘要:题目: 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] 阅读全文
posted @ 2019-07-10 16:37 silentteller 阅读(266) 评论(0) 推荐(0)
摘要:题目: 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] 阅读全文
posted @ 2019-07-10 13:59 silentteller 阅读(393) 评论(0) 推荐(0)