JinFei's Blog

Thinking will not overcome fear but action will.

[LeetCode]1539. Kth Missing Positive Number

模拟

题目描述 Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Find the kth positive integer that is missing from this array. Example1: Input: arr =...

[LeetCode]926. Flip String to Monotone Increasing

DP

题目描述 A binary string is monotone increasing if it consists of some number of 0’s (possibly none), followed by some number of 1’s (also possibly none). You are given a binary string s. You can ...

[LeetCode]827. Making A Large Island

DFS

题目描述 You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-...

[LeetCode]429. N-ary Tree Level Order Traversal

BFS

题目描述 Given an n-ary tree, return the level order traversal of its nodes’ values. Nary-Tree input serialization is represented in their level order traversal, each group of children is separate...

[LeetCode]337. House Robber III

回溯,递归法

题目描述 The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. A...

[LeetCode]124. Binary Tree Maximum Path Sum

二叉树的最大路径和

题目描述 Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent...

[LeetCode]295. Find Median from Data Stream

优先级队列的使用

题目描述 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 two middle value. For example, ...

[LeetCode]55. Jump Game

dp找状态转移方程

题目描述 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determ...

[LeetCode]24. Swap Nodes in Pairs

两两交换链表节点

题目描述 Given a linked list, swap every two adjacent nodes and return its head. Example 1: Input: head = [1,2,3,4] Output: [2,1,4,3] Example 2: Input: head = [] Output: [] Constraints: ...

[LeetCode]543. Diameter of Binary Tree

树的递归求高度的应用

题目描述 Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path m...