- 博客(2267)
- 问答 (1)
- 收藏
- 关注
原创 LeetCode //C - 927. Three Equal Parts
Summary: The problem requires dividing an array of binary digits into three non-empty parts that represent the same binary value. The solution involves counting the total number of 1's, ensuring it's divisible by three, and then verifying that the binary p
2025-11-24 07:15:00
930
原创 LeetCode //C - 926. Flip String to Monotone Increasing
Summary: The problem requires converting a binary string into a monotone increasing sequence (all 0s followed by all 1s) with the minimum number of flips. The solution involves scanning the string while tracking the number of 1s encountered. For each 0, th
2025-11-23 07:15:00
1634
原创 LeetCode //C - 925. Long Pressed Name
This problem checks if a typed string could be a long-pressed version of a name. The solution uses two pointers to traverse both strings simultaneously. If characters match, both pointers advance. If the typed character repeats (long press), only its point
2025-11-22 07:15:00
734
原创 LeetCode //C - 924. Minimize Malware Spread
This problem involves minimizing malware spread in a network by strategically removing an infected node. The solution uses Union-Find (Disjoint Set Union) to identify connected components. Key steps: Union all connected nodes to form components. Count comp
2025-11-21 07:15:00
722
原创 LeetCode //C - 923. 3Sum With Multiplicity
Summary: The problem involves counting all possible triplets (i, j, k) in an array where (i < j < k) and their sum equals a target value. The solution uses frequency counting to efficiently handle duplicates and modular arithmetic to prevent overflow
2025-11-20 07:15:00
1056
原创 LeetCode //C - 922. Sort Array By Parity II
Summary:Given an integer array nums, half of which is odd and half is even. Rearrange the array so that all even numbers are at even indices and all odd numbers are at odd indices. This can be achieved using a two-pointer method: one pointer, even, starts
2025-11-19 07:15:00
905
原创 LeetCode //C - 921. Minimum Add to Make Parentheses Valid
This problem requires finding the minimum number of insertions needed to make a parentheses string valid. The solution uses two counters: balance tracks unmatched '(', and add counts extra ')' needing a '(' before them. As we traverse the string, we adjust
2025-11-18 07:15:00
955
原创 LeetCode //C - 920. Number of Music Playlists
This problem requires calculating the number of music playlists that meet certain conditions. Given n different songs, you need to create a playlist of length goal, where each song is played at least once, and repeated songs must be separated by k other so
2025-11-17 07:15:00
1332
原创 LeetCode //C - 919. Complete Binary Tree Inserter
Summary: This problem involves maintaining a complete binary tree (CBT) where all levels except possibly the last are fully filled, and nodes are left-aligned. The solution implements a CBTInserter class with three methods: Initialization (cBTInserterCreat
2025-11-16 07:15:00
978
原创 LeetCode //C - 918. Maximum Sum Circular Subarray
This problem involves finding the maximum subarray sum in a circular array. The solution considers two cases: the maximum subarray may either lie within the array (non-circular) or wrap around the end (circular). The key is to compute the maximum subarray
2025-11-15 07:15:00
777
原创 LeetCode //C - 917. Reverse Only Letters
The problem requires reversing only the English letters in a string while keeping other characters in their original positions. The solution uses a two-pointer approach: one starting from the beginning (left) and the other from the end (right). The pointer
2025-11-14 07:15:00
810
原创 LeetCode //C - 916. Word Subsets
This article summarizes the solution to LeetCode Problem 916, which requires finding all common strings in words1 that satisfy a subset of all strings in words2. The key idea is:First, the maximum number of characters required for each character in all s
2025-11-13 07:15:00
1001
原创 LeetCode //C - 915. Partition Array into Disjoint Intervals
Summary:The task requires finding the smallest split point in an array, dividing it into a left and a right half, such that all elements in the left half are ≤ all elements in the right half. A single traversal maintains two variables: leftMax (the maximu
2025-11-12 07:15:00
1075
原创 LeetCode //C - 914. X of a Kind in a Deck of Cards
Summary: The problem checks if a deck of cards can be partitioned into groups where each group has the same number of cards (x > 1) and all cards in a group have the same value. Key Insight: The group size x must be a divisor of the count of every disti
2025-11-11 07:15:00
1320
原创 LeetCode //C - 913. Cat and Mouse
Summary: The problem models a Cat and Mouse game on an undirected graph where players alternate moves. The mouse starts at node 1, the cat at node 2, and the hole is at node 0. The game ends if the cat catches the mouse (cat wins), the mouse reaches the ho
2025-11-10 07:15:00
591
原创 LeetCode //C - 912. Sort an Array
This problem requires sorting an array of integers in ascending order with a time complexity of O(n log n) and without using built-in functions. Using the merge sort algorithm, the algorithm recursively splits the array into two halves, sorts each, and the
2025-11-09 07:15:00
646
原创 LeetCode //C - 911. Online Election
Summary: The problem involves tracking the leading candidate in an election over time, where votes are cast at specific times. The solution requires preprocessing the vote data to determine the leader after each vote and efficiently answering queries about
2025-11-08 07:15:00
1748
原创 LeetCode //C - 910. Smallest Range II
Summary: The problem requires modifying each element in an array by either adding or subtracting a given integer ( k ) to minimize the difference between the maximum and minimum values in the resulting array. Key Steps: Sort the Array: Ensures that potenti
2025-11-07 07:15:00
910
原创 LeetCode //C - 909. Snakes and Ladders
This problem involves finding the minimum number of moves to reach the end of a Snakes and Ladders game on an n x n board. The solution uses BFS to explore all possible moves from each position, simulating dice rolls (1-6) and handling snakes/ladders by ju
2025-11-06 07:15:00
1295
原创 LeetCode //C - 908. Smallest Range I
Summary: The problem requires minimizing the difference between the maximum and minimum values in an array after adjusting each element by at most ±k. The solution involves: Finding the current minimum (mn) and maximum (mx) values in the array. Calculating
2025-11-05 07:15:00
1941
原创 LeetCode //C - 907. Sum of Subarray Minimums
The problem involves finding the sum of minimum values of all contiguous subarrays in a given array. The solution utilizes a monotonic stack to efficiently compute for each element the number of subarrays where it is the minimum. Key steps: Use a stack to
2025-11-04 07:15:00
1452
原创 LeetCode //C - 906. Super Palindromes
Article Abstract:The task requires counting the number of "super palindromes" within a given interval [left, right]. A super palindrome must satisfy two conditions: it must be a palindrome itself and the square of another palindrome. Since the data range
2025-11-03 07:15:00
770
原创 LeetCode //C - 905. Sort Array By Parity
This problem requires moving all even numbers to the front of an array and odd numbers to the back. The solution uses a two-pointer approach: one pointer (left) starts at the beginning to place even numbers, while another (right) starts at the end to place
2025-11-02 07:15:00
345
原创 LeetCode //C - 904. Fruit Into Baskets
Problem: Given an array representing fruits on trees, collect the maximum number of fruits using two baskets, each holding only one type of fruit. Starting from any tree, you pick one fruit from each subsequent tree until encountering a fruit type not in y
2025-11-01 07:15:00
1714
原创 LeetCode //C - 903. Valid Permutations for DI Sequence
Summary: The problem involves counting valid permutations of integers 0 to n that satisfy given 'D' (decreasing) and 'I' (increasing) constraints. The solution uses dynamic programming (DP) with prefix sums to efficiently compute the number of valid permut
2025-10-31 07:15:00
896
原创 LeetCode //C - 902. Numbers At Most N Given Digit Set
Summary: The problem involves counting the number of positiveulinpositive integers that can be formed using a given digit setLedgerdigit set, where each digitilsdigit can be used multiple times, and the generated numbers are less than or equal to a given i
2025-10-30 07:15:00
1957
原创 LeetCode //C - 901. Online Stock Span
Summary: The problem involves designing a StockSpanner class that computes the "span" of a stock's price for each day, defined as the number of consecutive prior days (including the current day) where the stock price was less than or equal to the
2025-10-29 07:15:00
2059
原创 LeetCode //C - 900. RLE Iterator
Summary: The problem involves implementing an iterator for a run-length encoded (RLE) array. The RLE array consists of pairs of elements where the first element of each pair represents the count of the second element's occurrences. The RLEIterator class in
2025-10-28 07:15:00
837
原创 LeetCode //C - 899. Orderly Queue
SummaryThe problem requires finding the lexicographically minimum string by selecting one of the first k characters of a string at a time and moving it to the end, performing any number of operations. When k = 1, the only way to find the lexicographically
2025-10-27 07:15:00
587
原创 LeetCode //C - 898. Bitwise ORs of Subarrays
This article describes how to efficiently count the number of unique values in the bitwise OR operation for all non-empty subarrays in an array. The key idea is to maintain a dynamic hash set and gradually construct the OR result set for each subarray en
2025-10-26 07:15:00
1765
原创 LeetCode //C - 897. Increasing Order Search Tree
Summary: The problem requires rearranging a binary search tree into an in-order increasing tree where each node has no left child and only a right child. The solution involves performing an in-order traversal of the tree, relinking nodes to form a right-sk
2025-10-25 07:15:00
1263
原创 LeetCode //C - 896. Monotonic Array
This problem determines whether an array is monotonic (increasing or decreasing). By maintaining two Boolean flags, nonDecreasing and nonIncreasing, the relationship between adjacent elements is checked while traversing the array, and the corresponding fla
2025-10-24 07:15:00
1183
原创 LeetCode //C - 895. Maximum Frequency Stack
Here's a concise summary:This paper implements a frequency stack (FreqStack) data structure that supports push and pop operations. Push pushes an element to the top of the stack, and pop pops the most frequently occurring element (if the frequencies are t
2025-10-23 07:15:00
613
原创 LeetCode //C - 894. All Possible Full Binary Trees
This problem requires generating all possible full binary trees with a given number of nodes n, where each node has either 0 or 2 children. The solution uses dynamic programming with memoization to avoid recomputation. Key steps: Base Case: For n = 1, retu
2025-10-22 07:15:00
1178
原创 LeetCode //C - 893. Groups of Special-Equivalent Strings
This article introduces a method for determining special equivalent grouping of strings. The key is to understand the condition for special equivalence between two strings: the number of occurrences of each letter in both odd and even digits is the same. T
2025-10-21 00:00:00
1290
原创 LeetCode //C - 892. Surface Area of 3D Shapes
This problem requires computing the total surface area of a 3D shape composed of stacks of 1x1x1 cubes. The height of each cube is represented by a value in the grid. The solution consists of two main steps: first, computing the surface area of each in
2025-10-20 07:15:00
870
原创 LeetCode //C - 891. Sum of Subsequence Widths
Sorting an array: First, sort the array in ascending order, so that each element's position determines the number of times it is the maximum or minimum value in the subsequence.Precalculating powers: Preprocess the power-of-two array to avoid repeated cal
2025-10-19 07:15:00
1050
原创 LeetCode //C - 890. Find and Replace Pattern
This problem requires finding words that match a given pattern through character permutations. The solution involves checking each word against the pattern using bijective mapping (two-way character mapping) to ensure consistent one-to-one correspondences.
2025-10-18 07:15:00
723
原创 LeetCode //C - 889. Construct Binary Tree from Preorder and Postorder Traversal
Summary: The problem reconstructs a binary tree from its preorder and postorder traversals. The key idea is to use the first element in preorder as the root and the next element as the left subtree's root. By finding this left root in postorder, we determi
2025-10-17 07:15:00
972
原创 LeetCode //C - 888. Fair Candy Swap
Summary: This problem involves finding a fair candy swap between Alice and Bob such that both end up with equal total candies. The solution calculates the total candies each has, then determines the required difference for a valid swap. By using a presence
2025-10-16 07:15:00
677
空空如也
在函数中产生的指针变量无法在函数指针的参数中传递。
2023-10-09
用指向指针的指针动态分配二维数组后,再用指向指针的指针输入数据和输出数据出现问题。
2019-09-16
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅