- 博客(2153)
- 问答 (1)
- 收藏
- 关注
原创 LeetCode //C - 813. Largest Sum of Averages
This problem requires partitioning an array into at most k adjacent subarrays to maximize the sum of their averages. The solution uses dynamic programming with a prefix sum array to efficiently compute subarray averages. The dp[i][g] table stores the maxim
2025-08-02 07:15:00
564
原创 LeetCode //C - 812. Largest Triangle Area
This problem calculates the largest triangle area formed by any three distinct points on a 2D plane. The solution involves examining all possible triplets of points using three nested loops. For each triplet, the area is computed using the Shoelace formula
2025-08-01 07:15:00
441
原创 LeetCode //C - 811. Subdomain Visit Count
Algorithm Summary: The solution counts subdomain visits by parsing each input string into a visit count and domain, then iteratively processes all possible subdomains (e.g., "discuss.leetcode.com" → "leetcode.com" → "com"). A
2025-07-31 07:15:00
867
原创 LeetCode //C - 810. Chalkboard XOR Game
Summary: The problem involves a game where Alice and Bob take turns removing numbers from a chalkboard, with Alice starting first. A player loses if their move makes the XOR of all remaining numbers zero. The solution checks two conditions: if the initial
2025-07-30 07:15:00
614
原创 LeetCode //C - 809. Expressive Words
This problem checks if query words can be stretched to match a target string s by extending character groups (3+ identical letters). The solution involves: Group Matching: For each word, compare character groups between s and the word. Stretching Rules: If
2025-07-29 07:15:00
844
原创 LeetCode //C - 808. Soup Servings
This article discusses a problem about the probability of assigning two soups (A and B). Initially, there are n milliliters of soup each, and there are four choices for each operation, with a probability of 0.25 for each operation. When the operation canno
2025-07-28 07:15:00
972
原创 LeetCode //C - 807. Max Increase to Keep City Skyline
Summary: The problem requires maximizing the height increase of buildings in an n x n grid without altering the city's skyline from any cardinal direction. The skyline is determined by the tallest buildings in each row and column. For each building at posi
2025-07-27 07:15:00
630
原创 LeetCode //C - 805. Split Array With Same Average
This problem requires judging whether a given integer array can be divided into two non-empty sub-arrays so that their average values are equal. To avoid floating-point operations, we use mathematical transformation: as long as sum * n == totalSum * k (w
2025-07-26 00:15:00
629
原创 LeetCode //C - 806. Number of Lines To Write String
This problem calculates how many lines are needed to write a string s using given character widths, with each line not exceeding 100 pixels. The solution tracks the line count and current line width. For each character, it checks if adding its width exceed
2025-07-25 07:15:00
722
原创 LeetCode //C - 804. Unique Morse Code Words
Summary: The problem requires counting the number of unique Morse code transformations for a given list of words. Each letter is converted to its Morse code equivalent, and the transformations are formed by concatenating these codes. A hash set is used to
2025-07-24 07:15:00
1148
原创 LeetCode //C - 803. Bricks Falling When Hit
Summary: This problem involves simulating the effect of removing bricks from a grid and determining how many other bricks become unstable and fall as a result. The solution employs a Union-Find data structure to efficiently manage connectivity between bric
2025-07-23 07:15:00
1133
原创 LeetCode //C - 802. Find Eventual Safe States
This question requires finding all safe nodes in a directed graph. A safe node is defined as a node where all paths from the node eventually lead to a terminal node (a node with no outgoing edges) or other safe nodes. The following is a summary of the solu
2025-07-22 07:15:00
903
原创 LeetCode //C - 801. Minimum Swaps To Make Sequences Increasing
Abstract: This paper discusses how to make two arrays strictly increasing by the minimum number of swap operations. Given two arrays nums1 and nums2 of the same length, each operation allows the elements in the same position to be swapped. The solution use
2025-07-21 07:15:00
848
原创 LeetCode //C - 799. Champagne Tower
This problem simulates pouring champagne into a pyramid-shaped glass tower, where excess liquid from each glass spills equally into the two glasses below. The solution uses dynamic programming to track the champagne amount in each glass. For each glass, if
2025-07-20 07:15:00
660
原创 LeetCode //C - 798. Smallest Rotation with Highest Score
Solution Summary: The problem involves finding the optimal rotation index k for an array nums to maximize the score, where the score is the count of elements less than or equal to their new index after rotation. Key Steps: Difference Array: Use a differenc
2025-07-19 07:15:00
617
原创 LeetCode //C - 797. All Paths From Source to Target
This problem requires finding all possible paths from node 0 to node (n-1) in a directed acyclic graph (DAG). The solution uses Depth-First Search (DFS) to explore each path recursively. A temporary path array tracks the current traversal, and when the tar
2025-07-18 07:15:00
1231
原创 LeetCode //C - 796. Rotate String
Summary: The problem checks if string s can be rotated to match string goal by shifting its leftmost character to the right any number of times. The solution first verifies if s and goal have the same length. If they do, it concatenates s with itself and c
2025-07-17 07:15:00
283
原创 LeetCode //C - 795. Number of Subarrays with Bounded Maximum
This problem requires calculating the number of consecutive subarrays in an array that satisfy the maximum value of the subarray within a given interval. The core idea is to use the sliding window technology to efficiently count valid subarrays by maintain
2025-07-16 07:15:00
1732
原创 LeetCode //C - 794. Valid Tic-Tac-Toe State
This problem verifies whether a given Tic-Tac-Toe board state is legal. A legal state must meet the following conditions:Correct turn order: X goes first, O goes second, and the number of Xs must be equal to or one more than O.The win-lose state is leg
2025-07-15 07:15:00
692
原创 LeetCode //C - 793. Preimage Size of Factorial Zeroes Function
Abstract:The question requires calculating the number of non-negative integers x whose number of trailing zeros in factorial equals k. The key idea is to use binary search to determine the smallest x such that f(x)=k. If such an x exists, then 5 consecu
2025-07-14 07:15:00
568
原创 LeetCode //C - 792. Number of Matching Subsequences
Summary: This solution efficiently counts the number of words in a given list that are subsequences of a string s. It uses a queue-based approach where words are initially grouped by their first character. As each character in s is processed, words waiting
2025-07-13 07:15:00
1428
原创 LeetCode //C - 791. Custom Sort String
The problem requires custom sorting string s based on the order of characters in string order. Approach: Count Frequencies: Use an array to count how often each character appears in s. Build Result: Traverse order and append characters from s in the specif
2025-07-12 07:15:00
619
原创 LeetCode //C - 790. Domino and Tromino Tiling
Summary: This problem counts the ways to tile a 2×n board using domino and tromino shapes, allowing rotations. The solution employs dynamic programming with base cases for n=0 (1 way), n=1 (1 way), and n=2 (2 ways). The recurrence relation dp[i] = dp[i-1]
2025-07-11 07:15:00
2101
原创 LeetCode //C - 789. Escape The Ghosts
Summary: The problem determines if a player can escape ghosts in a 2D grid by reaching a target before any ghost. The solution hinges on comparing Manhattan distances: the player's distance from the target versus each ghost's distance. If any ghost can rea
2025-07-10 00:30:00
886
原创 LeetCode //C - 788. Rotated Digits
Summary: The problem requires counting "good" numbers between 1 and n. A good number becomes a different valid number when each digit is rotated 180 degrees. Valid digits include 0, 1, 8 (unchanged), 2, 5, 6, 9 (rotated to each other), while 3, 4
2025-07-09 04:15:00
925
原创 LeetCode //C - 787. Cheapest Flights Within K Stops
Summary: The problem requires finding the cheapest flight path from a source city to a destination city with at most k stops. Using a modified Bellman-Ford algorithm, the solution iteratively relaxes all flight edges for k+1 iterations (representing k stop
2025-07-08 07:15:00
1256
原创 LeetCode //C - 786. K-th Smallest Prime Fraction
This problem finds the k-th smallest fraction formed by dividing elements from a sorted array of primes (with 1). The solution uses a min-heap approach to efficiently track fractions without generating all possible pairs. Key steps: Initialize a heap with
2025-07-07 07:00:00
650
原创 LeetCode //C - 785. Is Graph Bipartite?
Abstract:Determine whether an undirected graph is bipartite. A bipartite graph requires that the nodes can be divided into two sets, and each edge connects nodes in different sets. Use DFS or BFS to traverse the graph, mark the nodes with two colors, and
2025-07-06 06:00:00
573
原创 LeetCode //C - 784. Letter Case Permutation
This problem generates all possible permutations of a string by changing letter cases while keeping digits unchanged. The solution uses backtracking: for each character, it recursively explores both lowercase and uppercase versions if it's a letter, or kee
2025-07-05 07:15:00
245
原创 LeetCode //C - 783. Minimum Distance Between BST Nodes
Problem Summary: Given a Binary Search Tree (BST), find the smallest difference between any two distinct node values. Solution Approach: The solution uses in-order traversal to visit nodes in ascending order. By keeping track of the previous node value dur
2025-07-04 07:15:00
1501
原创 LeetCode //C - 782. Transform to Chessboard
Summary: The problem requires transforming a given n x n binary grid into a chessboard pattern (no adjacent 0's or 1's) by swapping rows or columns, returning the minimum moves or -1 if impossible. The solution involves validating the grid's structure, che
2025-07-03 07:15:00
609
原创 LeetCode //C - 781. Rabbits in Forest
Summary: The problem involves calculating the minimum number of rabbits in a forest based on their answers about how many others share their color. Each rabbit's answer k implies k+1 rabbits of the same color. To minimize the total, we group rabbits with t
2025-07-02 07:00:00
1733
原创 LeetCode //C - 780. Reaching Points
Summary: This problem checks if we can transform point (sx, sy) to (tx, ty) by repeatedly adding one coordinate to the other (x, y) → (x, x+y) or (x+y, y). The solution works backward from (tx, ty) to (sx, sy), using modulo operations to efficiently "
2025-07-01 07:00:00
614
原创 LeetCode //C - 779. K-th Symbol in Grammar
Topic introduction:In the syntax table, the first row is 0, and each subsequent row is generated by the previous row: 0 becomes 01, 1 becomes 10. Given n and k, find the value of the kth bit in the nth row (1-indexed).Method idea:Using recursion and div
2025-06-30 06:45:00
1018
原创 LeetCode //C - 778. Swim in Rising Water
Summary: The problem requires finding the minimum time (water level) needed to swim from the top-left to the bottom-right of a grid, where swimming is only possible when the water level is at least the elevation of both adjacent cells. The solution employs
2025-06-29 07:15:00
617
原创 LeetCode //C - 777. Swap Adjacent in LR String
Summary: The problem checks if we can transform string start into result by swapping adjacent 'X' with 'L' or 'R'. The key observations are: 'L' can only move left (its index in start ≥ in result). 'R' can only move right (its index in start ≤ in result).
2025-06-28 07:15:00
1507
原创 LeetCode //C - 775. Global and Local Inversions
This problem checks whether the number of global inversions in a permutation equals the number of local inversions. A local inversion is a global inversion where the elements are adjacent. To ensure equality, all elements must be at most one position away
2025-06-27 07:15:00
1035
原创 LeetCode //C - 773. Sliding Puzzle
This problem involves solving a 2x3 sliding puzzle by finding the minimum number of moves to reach the target state [[1,2,3],[4,5,0]]. The solution uses BFS to explore all possible board configurations, tracking visited states to avoid cycles. Each move sw
2025-06-26 07:15:00
1824
原创 LeetCode //C - 771. Jewels and Stones
This problem counts how many stones are also jewels given two strings. The solution uses a lookup table (boolean array) to mark jewel characters for O(1) checks. It iterates through stones, counting matches with jewels. The approach efficiently handles cas
2025-06-25 07:15:00
921
原创 LeetCode //C - 770. Basic Calculator IV
This problem involves evaluating and simplifying algebraic expressions with variables. The solution requires parsing the expression, handling operator precedence, substituting variable values, combining like terms, and formatting the output according to sp
2025-06-24 07:15:00
708
空空如也
在函数中产生的指针变量无法在函数指针的参数中传递。
2023-10-09
用指向指针的指针动态分配二维数组后,再用指向指针的指针输入数据和输出数据出现问题。
2019-09-16
TA创建的收藏夹 TA关注的收藏夹
TA关注的人