- 博客(2300)
- 问答 (1)
- 收藏
- 关注
原创 LeetCode //C - 960. Delete Columns to Make Sorted III
This article introduces how to solve LeetCode problem 960: Sort an array of strings by removing columns. The goal of this problem is to find the minimum number of columns to remove so that the remaining rows of strings are lexicographically ordered.Core
2025-12-27 07:15:00
1049
原创 LeetCode //C - 959. Regions Cut By Slashes
This problem involves counting the number of regions formed by slashes (/, ) and spaces in an n x n grid. Each cell is divided into four triangles, and connections between these triangles are managed based on the cell's character. The solution uses a Union
2025-12-26 07:15:00
1384
原创 LeetCode //C - 958. Check Completeness of a Binary Tree
Summary: The problem determines if a binary tree is complete, where all levels except possibly the last are fully filled, and nodes in the last level are left-aligned. The solution employs BFS (level-order traversal) to scan the tree. If a NULL node is enc
2025-12-25 07:15:00
832
原创 LeetCode //C - 957. Prison Cells After N Days
Abstract: This problem describes the initial state of 8 prison cells. The current cell state is updated daily based on the states of adjacent cells (the first and last cells are always 0). Given the number of days n, return the cell state after day n. Sinc
2025-12-24 07:15:00
653
原创 LeetCode //C - 956. Tallest Billboard
Problem Summary: Given a set of rods, find two subsets with equal sums (representing the heights of two billboard supports) such that their common sum is maximized. If no such subsets exist, return 0. Key Insights: The problem reduces to partitioning the r
2025-12-23 07:15:00
1311
原创 LeetCode //C - 955. Delete Columns to Make Sorted II
Problem Summary: Given an array of strings of equal length, we need to delete the minimum number of columns (indices) such that the remaining strings are in lexicographic order. Key Insights: Left-to-Right Column Scan: Process columns sequentially to deter
2025-12-22 07:15:00
1243
原创 LeetCode //C - 954. Array of Doubled Pairs
Abstract: The problem asks whether a given even-length array can be reordered such that each odd-numbered element is twice the number of its preceding element. The solution is to count the frequency of each element, sort the array by absolute value, and th
2025-12-21 07:15:00
1718
原创 LeetCode //C - 953. Verifying an Alien Dictionary
Summary: The problem involves verifying if a list of words is sorted according to a custom alien alphabet order. The solution involves creating a rank mapping for each character based on the given order. It then compares adjacent words character by charact
2025-12-20 07:15:00
693
原创 LeetCode //C - 952. Largest Component Size by Common Factor
This problem involves finding the largest connected component in a graph where nodes are connected if they share a common factor greater than 1. The solution efficiently uses the Union-Find (DSU) data structure combined with prime factorization to connect
2025-12-19 07:15:00
1624
原创 LeetCode //C - 951. Flip Equivalent Binary Trees
Summary: The problem determines if two binary trees are flip equivalent, meaning one can be transformed into the other via any number of subtree swaps. The solution uses recursion to check at each node whether the subtrees match either in their original or
2025-12-18 07:15:00
855
原创 LeetCode //C - 950. Reveal Cards In Increasing Order
Abstract: The problem requires sorting a deck of cards with unique integer numbers such that, when flipped in sequence according to a specific step (each time the top card is flipped and the next top card is moved to the bottom), the card numbers are in as
2025-12-17 07:15:00
1985
原创 LeetCode //C - 949. Largest Time for Given Digits
Summary: This problem requires generating the latest valid 24-hour time ("HH:MM") from four given digits, ensuring each digit is used exactly once. The solution involves: Enumerating all permutations of the digits to form possible HH and MM combi
2025-12-16 07:15:00
1069
原创 LeetCode //C - 948. Bag of Tokens
The problem involves maximizing a score by strategically playing tokens either face-up (spending power to gain score) or face-down (spending score to gain power). The solution involves sorting the tokens and using a two-pointer approach to balance between
2025-12-15 07:15:00
990
原创 LeetCode //C - 947. Most Stones Removed with Same Row or Column
This problem involves removing stones that share a row or column with another stone. The solution uses Union-Find (Disjoint Set Union) to group connected stones into components. The key observation is that in each component, all stones except one can be re
2025-12-14 07:15:00
1447
原创 LeetCode //C - 946. Validate Stack Sequences
Summary: This problem checks if a given popped sequence can be obtained from a pushed sequence using stack operations. We simulate the stack by pushing elements from pushed and popping them when they match the next element in popped. If all elements in pop
2025-12-13 07:15:00
630
原创 LeetCode //C - 945. Minimum Increment to Make Array Unique
Summary: This problem requires making all elements in an array unique by incrementing duplicate values with the minimum number of moves. The solution involves sorting the array first, then traversing it to detect duplicates. For each duplicate, we calculat
2025-12-12 07:15:00
1476
原创 LeetCode //C - 944. Delete Columns to Make Sorted
Summary: The problem involves determining the number of columns to delete from a grid of strings to ensure all remaining columns are sorted lexicographically. The solution iterates through each column, checks if it is sorted by comparing adjacent character
2025-12-11 07:15:00
607
原创 LeetCode //C - 943. Find the Shortest Superstring
This problem involves finding the shortest string that contains all given words as substrings. The solution uses dynamic programming with bitmasking to efficiently compute the optimal order of words by maximizing overlaps between them. Key steps: Precomput
2025-12-10 07:15:00
1364
原创 LeetCode //C - 942. DI String Match
Problem Summary: Given a string s consisting of characters 'I' (increase) and 'D' (decrease), reconstruct a permutation perm of integers from 0 to n (where n = s.length) that satisfies the conditions: For 'I': perm[i] < perm[i+1] For 'D': perm[i] > p
2025-12-09 07:15:00
1027
原创 LeetCode //C - 941. Valid Mountain Array
Summary: The problem checks if an array is a valid mountain array, which must: Have length ≥ 3 Strictly increase to a peak (not at the ends) Strictly decrease after the peak End at the last element Approach: Traverse up while strictly increasing. Ensure th
2025-12-08 07:15:00
1108
原创 LeetCode //C - 940. Distinct Subsequences II
This problem requires counting the number of distinct non-empty subsequences of a given string. The solution uses dynamic programming to efficiently track subsequences while avoiding duplicates. Key Idea: For each character in the string, we consider two c
2025-12-07 07:15:00
918
原创 LeetCode //C - 939. Minimum Area Rectangle
Abstract: Given a set of points on a plane, calculate the minimum area of a rectangle formed by these points with sides parallel to the coordinate axes. If no such rectangle exists, return 0. Solution: Sort the points and iterate through all possible pai
2025-12-06 07:15:00
919
原创 LeetCode //C - 938. Range Sum of BST
Summary: The problem requires summing the values of nodes within a given range [low, high] in a binary search tree (BST). The solution leverages the BST property to optimize traversal. If a node's value is below low, only the right subtree is explored (lef
2025-12-05 07:15:00
552
原创 LeetCode //C - 937. Reorder Data in Log Files
This problem involves reordering log files based on specific criteria. The solution separates logs into letter-logs (containing letters after the identifier) and digit-logs (containing digits). Letter-logs are sorted lexicographically by their content, wit
2025-12-04 07:15:00
1877
原创 LeetCode //C - 936. Stamping The Sequence
This article explores how to transform an initial string consisting entirely of question marks into a target string through a series of operations. Each operation overwrites a position in the current string with a stamped string, replacing the correspondin
2025-12-03 07:15:00
2172
原创 LeetCode //C - 935. Knight Dialer
Summary: The problem involves counting distinct phone numbers of length n where each digit transition follows the chess knight's move pattern on a phone pad. The solution uses dynamic programming (DP) to track the number of valid sequences ending at each d
2025-12-02 07:15:00
848
原创 LeetCode //C - 934. Shortest Bridge
Summary: The problem requires finding the minimum number of water cells (0s) to flip to connect two distinct islands (4-directionally connected 1s) in a binary matrix. The solution involves: Identifying and marking one island (changing 1s to 2s) and enqueu
2025-12-01 07:15:00
734
原创 LeetCode //C - 933. Number of Recent Calls
The problem involves tracking recent requests within a 3000-millisecond window. The solution uses a RecentCounter class with a dynamically expanding array to store request timestamps. The key optimization is maintaining a sliding window by moving a head po
2025-11-30 07:15:00
919
原创 LeetCode //C - 932. Beautiful Array
This problem requires constructing a "beautiful array" of length n, where no element is the average of any two other elements. The solution uses a constructive approach: Start with the base array [1] Iteratively expand the array by first adding o
2025-11-29 07:15:00
954
原创 LeetCode //C - 931. Minimum Falling Path Sum
Summary: This problem involves finding the minimum sum of any falling path through a square matrix, where a path can move directly down or diagonally left/right. The solution uses dynamic programming to build the minimum path sum row by row, with each cell
2025-11-28 07:15:00
1070
原创 LeetCode //C - 930. Binary Subarrays With Sum
Abstract: The problem asks to find the number of subarrays in a binary array whose sum equals a given target value. Using the prefix sum concept, the problem is transformed into counting the number of times the prefix difference equals the target value. An
2025-11-27 07:15:00
1368
原创 LeetCode //C - 929. Unique Email Addresses
This problem requires counting the number of distinct email addresses that actually received the emails. The processing rules include:The period ('.') in the locale name is ignored; for example, "alice.z@leetcode.com" and "alicez@leetcode.com" are consid
2025-11-26 07:15:00
1386
原创 LeetCode //C - 928. Minimize Malware Spread II
Approach The problem involves minimizing the spread of malware in a network by removing one initially infected node. The solution involves simulating the removal of each infected node and calculating the resulting spread of malware from the remaining infec
2025-11-25 07:15:00
1520
原创 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
2067
原创 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
1915
原创 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
756
原创 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
752
原创 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
1106
原创 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
955
原创 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
1015
空空如也
在函数中产生的指针变量无法在函数指针的参数中传递。
2023-10-09
用指向指针的指针动态分配二维数组后,再用指向指针的指针输入数据和输出数据出现问题。
2019-09-16
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅