JinFei's Blog

Thinking will not overcome fear but action will.

[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. Example1: Input: [2,3,-2,4] Output: 6 Expl...

[LeetCode]238. Product of Array Except Self

不用乘法做乘积

题目描述 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 nums except nums[i]. NOTE Please solve it wit...

[LeetCode]406. Queue Reconstruction by Height

排序的应用

题目描述 Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in fro...

[LeetCode]416. Partition Equal Subset Sum

dp,背包问题

题目描述 Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. NOTE Each of t...

[LeetCode]96. Unique Binary Search Trees

卡塔兰数

题目描述 Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n? Example1: Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5 unique BST...

[LeetCode]207. Course Schedule

有向图的表示

题目描述 There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expres...

[LeetCode]146. LRU Cache

双向链表,LRU的规则

题目描述 Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of t...

[LeetCode]98. Validate Binary Search Tree

考察中序遍历,二叉搜索树

题目描述 Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node’s...

[LeetCode]300. Longest Increasing Subsequence

dp,最长递增子序列

题目描述 Given an unsorted array of integers, find the length of longest increasing subsequence. Example1: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subse...

[LeetCode]79. Word Search

dfs搜索

题目描述 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or v...