自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Made in Code

Everything is Math, everything is Code!

  • 博客(2144)
  • 问答 (1)
  • 收藏
  • 关注

原创 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 485

原创 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 581

原创 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 825

原创 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 833

原创 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 652

原创 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 614

原创 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 1219

原创 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 276

原创 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 1718

原创 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 684

原创 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 561

原创 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 1419

原创 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 614

原创 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 2089

原创 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 875

原创 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 916

原创 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 1250

原创 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 647

原创 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 570

原创 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 242

原创 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 1492

原创 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 603

原创 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 1731

原创 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 606

原创 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 1012

原创 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 613

原创 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 1495

原创 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 1022

原创 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 1817

原创 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 910

原创 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 703

原创 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 1537

原创 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 518

原创 LeetCode //C - 767. Reorganize String

This solution addresses the problem of reorganizing a string such that no two adjacent characters are identical. The approach involves:Frequency Counting: Calculating the frequency of each character in the input string.Feasibility Check: Ensuring it's p

2025-06-21 07:15:00 355

原创 LeetCode //C - 766. Toeplitz Matrix

This problem checks if a given matrix is Toeplitz, meaning all elements in each diagonal (from top-left to bottom-right) are identical. The solution iterates through each element (except the last row and column) and verifies if it matches the element diago

2025-06-20 07:15:00 432

原创 LeetCode //C - 765. Couples Holding Hands

Summary:The problem requires arranging couples side by side in a row of seats with minimal swaps. Each couple consists of consecutive IDs (e.g., 0-1, 2-3). The solution iterates through seat pairs, checks if the current pair forms a couple, and swaps if n

2025-06-19 07:15:00 1535

原创 LeetCode //C - 764. Largest Plus Sign

This approach efficiently checks each cell's potential to be the center of a plus sign by leveraging precomputed counts of consecutive 1s in all directions, ensuring optimal performance.

2025-06-18 07:15:00 1893

原创 LeetCode //C - 762. Prime Number of Set Bits in Binary Representation

This problem requires counting numbers in a given range [left, right] that have a prime number of set bits (1's) in their binary representation. The solution involves three key steps: checking if a number is prime, counting the set bits of a number, and it

2025-06-17 07:15:00 1005

原创 LeetCode //C - 761. Special Binary String

This problem requires that the result with the largest lexicographic order be obtained by exchanging consecutive special substrings in a special binary string. The solution adopts a recursive divide-and-conquer strategy:Basic processing: Strings with len

2025-06-16 07:15:00 1102

原创 LeetCode //C - 757. Set Intersection Size At Least Two

This problem requires finding the smallest set of numbers that intersects each given interval in at least two points. The solution involves sorting the intervals by their end points and processing them in order. For each interval, we check how many of our

2025-06-15 07:15:00 1059

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除