Skip to content

Latest commit

 

History

History

残酷刷题

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

残酷刷题群

Problems

前缀和

    1. Maximum Number of Ways to Partition an Array
    1. Sum of Absolute Differences in a Sorted Array
    1. Intervals Between Identical Elements
    1. Rectangle Area II, 二维差分
    1. Stamping the Grid
    1. Corporate Flight Bookings: 差分
    1. Number of Flowers in Full Bloom: 差分
    1. Minimum Moves to Make Array Complementary

排序

    1. The Number of Weak Characters in the Game
    1. Find Original Array From Doubled Array

Quick Select

    1. K Closest Points to Origin
    1. Top K Frequent Elements

双指针

    1. Minimum Number of Operations to Make Array Continuousg
    1. Max Consecutive Ones III
    1. Maximize the Confusion of an Exam
    1. Longest Repeating Character Replacement
    1. Binary Subarrays With Sum
    1. Maximum Fruits Harvested After at Most K Steps
    1. Number of Subsequences That Satisfy the Given Sum Condition

    1. Sequentially Ordinal Rank Tracker
    1. Minimum Difference in Sums After Removal of Elements
    1. Minimum Cost to Make at Least One Valid Path in a Grid: 搜索
    1. Path with Maximum Probability
    1. Reachable Nodes In Subdivided Graph: dijkstra
    1. Cheapest Flights Within K Stops: 二维的 dijkstra,有点类似 dp 的思想

单调栈

    1. Remove Duplicate Letters
    1. Remove K Digits
    1. Trapping Rain Water
    1. Maximum Subarray Min-Product

DP

    1. Minimum Total Space Wasted With K Resizing Operations
    1. Filling Bookcase Shelves
    1. Partition Array for Maximum Sum
    1. Number of Ways to Separate Numbers
    • LCS + 区间 DP
    1. Maximum Earnings From Taxi
    1. Maximum Profit in Job Scheduling
    1. Maximum Number of Events That Can Be Attended II
    1. Allocate Mailboxes
    • DP + 货仓选址
    1. Count Square Submatrices with All Ones
    1. Count Fertile Pyramids in a Land
    1. Paint House III
    • 线性 DP
    1. Count Substrings That Differ by One Character
    1. Minimum Time to Remove All Cars Containing Illegal Goods
    1. Minimum White Tiles After Covering With Carpets
  • 数位 DP
      1. Numbers With Repeated Digits
      1. Count Special Integers
      1. Non-negative Integers without Consecutive Ones

二分图

    1. Minimum Cost to Connect Two Groups of Points

状态压缩

    1. Minimum Number of Work Sessions to Finish the Tasks
    • 子集遍历
    1. Parallel Courses II
    1. Distribute Repeating Integers
    1. Maximum Product of the Length of Two Palindromic Subsequences
    1. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
    1. People Whose List of Favorite Companies Is Not a Subset of Another List

LIS (最长上升子序列)

    1. Longest Increasing Subsequence
    1. Find the Longest Valid Obstacle Course at Each Position
    1. Minimum Operations to Make a Subsequence
    1. Russian Doll Envelopes
    • w 递增,h 递减排序,在 h 上求 LIS 一定就是答案

背包

    1. Minimize the Difference Between Target and Chosen Elements

subsequence 计数

    1. Distinct Subsequences II
    1. Number of Unique Good Subsequences
    1. The Number of Good Subsets

二分查找

    1. Two Best Non-Overlapping Events
    1. Maximum Profit in Job Scheduling
    1. Maximum Number of Events That Can Be Attended II
    1. Sum of Mutated Array Closest to Target
    1. Maximum Value at a Given Index in a Bounded Array
    1. Ugly Number III.js
  • 二分 + 容斥原理 + lcm
    1. Sell Diminishing-Valued Colored Balls

并查集

    1. Graph Connectivity With Threshold
    1. Find All People With Secret
    • 并查集,宽搜都可以做
    1. Groups of Strings

时光倒流

    1. Last Day Where You Can Still Cross
    1. Bricks Falling When Hit

回文串 (DP / Manacher)

    1. Longest Palindromic Substring
    1. Maximum Product of the Length of Two Palindromic Substrings
    • Manacher + 双指针
    1. Shortest Palindrome

最短路

    1. Number of Ways to Arrive at Destination
    • 最短路 + DP

数学

质数筛

    1. Largest Component Size by Common Factor
    • 质数筛 + DP
    1. GCD Sort of an Array

公约数

    1. Count Array Pairs Divisible by K

搜索

    1. Longest Subsequence Repeated k Times
    1. Closest Subsequence Sum
    • 双向搜索

BFS

    1. Second Minimum Time to Reach Destination
    1. Minimum Moves to Move a Box to Their Target Location
    • Deque, 只有 0 和 1 两个边权
    1. Escape the Spreading Fire
    1. Detonate the Maximum Bombs
    1. Minimum Jumps to Reach Home
    1. Count Subtrees With Max Distance Between Cities

拓扑排序

    1. Course Schedule
    1. Course Schedule II
    1. Find All Possible Recipes from Given Supplies
    1. Minimum Height Trees
    • 无向图的拓扑排序

DFS

    1. Diameter of Binary Tree
    1. Longest Univalue Path
    1. Binary Tree Maximum Path Sum
    1. Number of Valid Move Combinations On Chessboard
    • 非常恶心的一道暴力题,怎么做都能做出来,但是就是题意复杂

位运算枚举

    1. Closest Dessert Cost

表达式求值

    1. Basic Calculator II
    1. Different Ways to Add Parentheses
    1. 24 Game

状态机

    1. Plates Between Candles

链表

    1. Reverse Linked List
    1. Reverse Linked List II
    1. Reverse Nodes in k-Group
    1. Reverse Nodes in Even Length Groups
    1. Reorder List

欧拉路径

    1. Reconstruct Itinerary
    1. Valid Arrangement of Pairs

LCA (最近公共祖先)

    1. Lowest Common Ancestor of a Binary Tree
    1. Lowest Common Ancestor of Deepest Leaves
    1. Step-By-Step Directions From a Binary Tree Node to Another

基环树

    1. Maximum Employees to Be Invited to a Meeting

字符串哈希

    1. Longest Duplicate Substring
    • 数据比较强,需要开较大的 Q 取模,只能用 BigInt
    1. Shortest Palindrome
    1. Find Substring With Given Hash Value
    1. Longest Common Subpath
    1. Sum of Scores of Built Strings
    • 双哈希,可以把 mod 调小一点,不用 BigInt,JS 的 BigInt 效率还是很慢,很容易超时

括号匹配

    1. Check if a Parentheses String Can Be Valid
    1. Longest Valid Parentheses

分治 (Divide and Conquer)

    1. Count of Smaller Numbers After Self
    1. Count Good Triplets in an Array

扫描线 (Sweep Line)

    1. Merge Intervals
    1. The Skyline Problem

线段树

    1. Range Module
    1. Longest Substring of One Repeating Character
    1. Booking Concert Tickets in Groups
    1. Maximum White Tiles Covered by a Carpet

Links