JinFei's Blog

Thinking will not overcome fear but action will.

[LeetCode]223. 矩形面积

矩形面积

题目描述 给你 二维 平面上两个 由直线构成的 矩形,请你计算并返回两个矩形覆盖的总面积。 每个矩形由其 左下 顶点和 右上 顶点坐标表示: 第一个矩形由其左下顶点 (ax1, ay1) 和右上顶点 (ax2, ay2) 定义。 第二个矩形由其左下顶点 (bx1, by1) 和右上顶点 (bx2, by2) 定义。 Example1: 输入:ax1 = -3, ay1 = ...

[LeetCode]297. Serialize and Deserialize Binary Tree

序列化二叉树

题目描述 Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection...

[LeetCode]2016. 增量元素之间的最大差值

元素之间的最大差值

题目描述 给你一个下标从 0 开始的整数数组 nums ,该数组的大小为 n ,请你计算 nums[j] - nums[i] 能求得的 最大差值 ,其中 0 <= i < j < n 且 nums[i] < nums[j] 。 返回 最大差值 。如果不存在满足要求的 i 和 j ,返回 -1 。 Example1: 输入:nums = [7,1,5,4...

[LeetCode]739. Daily Temperatures

递减栈

题目描述 Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future da...

[LeetCode]48. Rotate Image

原地矩阵旋转90度

题目描述 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input ...

[LeetCode]538. 把二叉搜索树转换为累加树

二叉搜索树转为累加树

题目描述 给出二叉 搜索 树的根节点,该树的节点值各不相同,请你将其转换为累加树(Greater Sum Tree),使每个节点 node 的新值等于原树中大于或等于 node.val 的值之和。 提醒一下,二叉搜索树满足下列约束条件: 节点的左子树仅包含键 小于 节点键的节点。 节点的右子树仅包含键 大于 节点键的节点。 左右子树也必须是二叉搜索树。 Example1: ...

[LeetCode]437. Path Sum III

树的路径和,递归

题目描述 You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need to start or end at the root or a leaf, b...

[LeetCode]394. Decode String

两个栈的使用

题目描述 Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note tha...

[LeetCode]438. Find All Anagrams in a String

子字符串出现的位置

题目描述 Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of both strings s and p will n...

[LeetCode]647. Palindromic Substrings

回文子串的数量

题目描述 Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even th...