
LeetCode
文章平均质量分 91
Navigator_Z
烈焰,在冰冷的海水中跳跃; 闪电,在自己的影子中熄灭。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
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 · 359 阅读 · 0 评论 -
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 · 469 阅读 · 0 评论 -
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 · 837 阅读 · 0 评论 -
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 · 969 阅读 · 0 评论 -
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 · 626 阅读 · 0 评论 -
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 · 721 阅读 · 0 评论 -
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 · 628 阅读 · 0 评论 -
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 · 1146 阅读 · 0 评论 -
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 · 1132 阅读 · 0 评论 -
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 · 900 阅读 · 0 评论 -
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 · 845 阅读 · 0 评论 -
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 · 658 阅读 · 0 评论 -
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 · 616 阅读 · 0 评论 -
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 · 1229 阅读 · 0 评论 -
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 · 282 阅读 · 0 评论 -
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 · 1729 阅读 · 0 评论 -
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 · 691 阅读 · 0 评论 -
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 · 563 阅读 · 0 评论 -
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 · 1426 阅读 · 0 评论 -
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 · 618 阅读 · 0 评论 -
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 · 2099 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 924 阅读 · 0 评论 -
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 · 1255 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 608 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 613 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 1032 阅读 · 0 评论 -
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 · 1823 阅读 · 0 评论 -
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 · 920 阅读 · 0 评论 -
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 阅读 · 0 评论 -
LeetCode //C - 769. Max Chunks To Make Sorted
This article discusses how to split a permutation array into the most blocks, so that each block can be sorted separately and then connected to form a globally ordered array. The key is to maintain the current maximum value when traversing the array. When原创 2025-06-23 07:15:00 · 1544 阅读 · 0 评论 -
LeetCode //C - 768. Max Chunks To Make Sorted II
Article summary:The question requires that the array be divided into as many blocks as possible, so that each block is sorted separately and then spliced together to be equal to the result of the original array after sorting. The key to the solution is:原创 2025-06-22 07:15:00 · 522 阅读 · 0 评论