[LeetCode] 918. Maximum Sum Circular Subarray

918. Maximum Sum Circular Subarray Hardness: \(\color{orange}\textsf{Medium}\) Ralated Topics: Array、Divide and Conquer、Dynamic Programming、Queue、Monotonic Queue 一、題目 Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums. A circular array means the end of the array connects to the beginning of the array. Formally, the next element of nums[i] is nums[(i + 1) % n] and the previous element of nums[i] is nums[(i - 1 + n) % n]....

<span title='2023-01-18 23:07:56 +0800 +0800'>January 18, 2023</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Rain Hu

[LeetCode] 926. Flip String to Monotone Increasing

926. Flip String to Monotone Increasing Hardness: \(\color{orange}\textsf{Medium}\) Ralated Topics: String、Dynamic Programming 一、題目 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 flip s[i] changing 0 to 1 or from 1 to 0. Return the minimum number of flips to make s monotone increasing. Example 1:...

<span title='2023-01-17 16:36:26 +0800 +0800'>January 17, 2023</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Rain Hu

[LeetCode] 1519. Number of Nodes in the Sub-Tree With the Same Level

1519. Number of Nodes in the Sub-Tree With the Same Level Hardness: \(\color{orange}\textsf{Medium}\) Ralated Topics: Hash Table、Tree、Depth-First Search、Breadth-First Search、Counting 一、題目 You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i....

<span title='2023-01-12 22:56:18 +0800 +0800'>January 12, 2023</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;Rain Hu

[LeetCode] 100. Same Tree

100. Same Tree Hardness: \(\color{green}\textsf{Easy}\) Ralated Topics: Tree、Depth-First Search、Breadth-First Search、Binary Tree 一、題目 Given the roots of two binary tree p and q, write a function to check if they are the same or not. Two binary tree are considered the same if they are structurally iedntical, and the nodes have the same value. Example 1: Input: p = [1,2,3], q = [1,2,3] Output: true Example 2: Input: p = [1,2], q = [1,null,2] Output: false Example 3: Input: p = [1,2,1], q = [1,1,2] Output: false Constraints:...

<span title='2023-01-10 21:48:09 +0800 +0800'>January 10, 2023</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Rain Hu

[LeetCode] 149. Max Points on a Line

149. Max Points on a Line Hardness: \(\color{red}\textsf{Hard}\) Ralated Topics: Array、Hash Table、Math、Geometry 一、題目 Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line. Example 1: Input: points = [[1,1],[2,2],[3,3]] Output: 3 Example 2: Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]] Output: 4 Constraints: 1 <= points.length <= 300 points[i].length == 2 -10^4 <= xi, yi <= 10^4 All the points are unique....

<span title='2023-01-08 23:44:07 +0800 +0800'>January 8, 2023</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Rain Hu