随笔分类 - 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Design and implement a data structure for Least Frequently Used (LFU)cache. It should support the following operations: get and put. get(key) - Ge
阅读全文
摘要:题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears
阅读全文
摘要:题目: Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination,
阅读全文
摘要:题目: Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Example 2: Note: Length o
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Count the number of prime numbers less than a non-negative number, n. Example: 分析: 统计所有小于非负整数 n 的质数的数量。 这里使用埃拉托斯特尼筛法。要得到自然数n以内的全部素数,必须把不大于√n的所有素数的
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a binary tree, return the postorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it itera
阅读全文
摘要:题目: 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]
阅读全文
摘要:题目: 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]
阅读全文

浙公网安备 33010602011771号