📈
notes
  • README
  • t
  • 0001_Two_Sum
    • 思路1 利用hash的思想
  • 0002_Add_Two_Numbers
    • 思路1 直接从左往右加
  • 0003_Longest_Substring_Without_Repeating_Characters
    • 思路1 HashMap存放字符到索引的映射
  • 0004_Median_of_Two_Sorted_Arrays
    • 思路1 转化为求Kth smallest的数
  • 0005_Longest_Palindromic_Substring
    • slt
  • 0006_ZigZag_Conversion
    • 思路1 利用字符串list进行转换
  • 0007_Reverse_Integer
    • slt
  • 0008_String_to_Integer_(atoi)
    • 思路1 遍历字符串
  • 0009_Palindrome_Number
    • slt
  • 0010_Regular_Expression_Matching
    • slt
  • 0011_Container_With_Most_Water
    • 思路1 从两边到中间宽度递减算water
  • 0012_Integer_to_Roman
    • slt
  • 0013_Roman_to_Integer
    • 思路1 比后面小减当前,比后面大加当前
  • 0014_Longest_Common_Prefix
    • 思路1 对每一列,遍历所有字符串,比较那一列的字符
  • 0015_3Sum
    • 思路1 排序后遍历所有组合
  • 0016_3Sum_Closest
    • 思路1 类似3sum的思路1
  • 0017_Letter_Combinations_of_a_Phone_Number
    • slt
  • 0018_4Sum
    • slt
  • 0019_Remove_Nth_Node_From_End_of_List
    • 思路1 快慢指针
  • 0020_Valid_Parentheses
    • slt
  • 0021_Merge_Two_Sorted_Lists
    • 思路1 遍历即可
  • 0022_Generate_Parentheses
    • 思路1 DFS
  • 0023_Merge_k_Sorted_Lists
    • 思路1 不断的两两merge
  • 0024_Swap_Nodes_in_Pairs
    • Solution 1 direct swap
  • 0025_Reverse_Nodes_in_k-Group
    • 思路1 k个分别反转,迭代实现
  • 0026_Remove_Duplicates_from_Sorted_Array
    • 思路1 就地算法
  • 0027_Remove_Element
    • 思路1 类似第26题,只是判断的对象是给定的一个val
  • 0028_Implement_strStr()
    • slt
  • 0029_Divide_Two_Integers
    • Solution 1 Use subtraction
  • 0030_Substring_with_Concatenation_of_All_Words
    • 思路1
  • 0031_Next_Permutation
    • 思路1
  • 0032 Longest Valid Parentheses
    • 思路1 利用一个栈来存放左括号的下标
  • 0033_Search_in_Rotated_Sorted_Array
    • 思路1 只对有序的那一半进行二分查找
  • 0034_Find_First_and_Last_Position_of_Element_in_Sorted_Array
    • 思路1 二分查找
  • 0035_Search_Insert_Position
    • 思路1 二分查找
  • 0036_Valid_Sudoku
    • Solution 1 hash_table, 利用3个二维数组一起检查
  • 0037_Sudoku_Solver
    • 思路1 回溯法
  • 0038_Count_and_Say
    • slt
  • 0039_Combination_Sum
    • 思路1 DFS
  • 0040_Combination_Sum_II
    • 思路1 DFS
  • 0041_First_Missing_Positive
    • 思路1 把数组中的正数按数值重新放在数组中
  • 0042_Trapping_Rain_Water
    • 思路1 从左右按矮的一方往中间逼近
  • 0043_Multiply_Strings
    • 思路1 利用双重循环模拟标准的乘法
  • 0044_Wildcard_Matching
    • slt
  • 0045_Jump_Game_II
    • 思路1 贪心算法
  • 0046_Permutations
    • 思路1 dfs
  • 0047_Permutations_II
    • 思路1 dfs
  • 0048_Rotate_Image
    • 思路1 先上下翻转,在转置
  • 0049_Group_Anagrams
    • 思路1
  • 0050_Pow(x, n)
    • 思路1 二分递归
  • 0051_N-Queens
    • 思路1 回溯法
  • 0052_N-Queens_II
    • 思路1 回溯法
  • 0053_Maximum_Subarray
    • 思路1 dp
  • 0054_Spiral_Matrix
    • 思路1 直接四个方向扫描
  • 0055_Jump_Game
    • 思路1 贪心算法
  • 0056_Merge_Intervals
    • 思路1 按照start排序,再合并
  • 0057_Insert_Interval
    • 思路1 贪心算法
  • 0058_Length_of_Last_Word
    • 思路1 从右向左遍历
  • 0059_Spiral_Matrix_II
    • 思路1 同Spiral Matrix1
  • 0060_Permutation_Sequence
    • 思路1 利用数学特征
  • 0061_Rotate_List
    • 思路1
  • 0062_Unique_Paths
    • slt
  • 0063_Unique_Paths_II
    • 思路1 dp
  • 0064_Minimum_Path_Sum
    • 思路1 还是dp
  • 0065_Valid_Number
    • slt
  • 0066_Plus_One
    • Solution 1 simulation
  • 0067_Add_Binary
    • 思路1
  • 0068_Text_Justification
    • 思路1 贪心 遍历words
  • 0069_Sqrt(x)
    • slt
  • 0070_Climbing_Stairs
    • slt
  • 0071_Simplify_Path
    • 思路1
  • 0072_Edit_Distance
    • 思路1 dp
  • 0073_Set_Matrix_Zeroes
    • 思路1
  • 0074_Search_a_2D_Matrix
    • 思路1
  • 0075_Sort_Colors
    • 思路1 遍历一次,遇到0放到前面,遇到2放到后面
  • 0076_Minimum_Window_Substring
    • 思路1 滑动窗口
  • 0077_Combinations
    • 思路1 dfs
  • 0078_Subsets
    • 思路1 Traceback
  • 0079_Word_Search
    • 思路1
  • 0080_Remove_Duplicates_from_Sorted_Array_II
    • 思路1
  • 0081_Search_in_Rotated_Sorted_Array_II
    • 思路1 只对有序的那一半进行二分查找
  • 0082_Remove_Duplicates_from_Sorted_List_II
    • 思路1 遍历一遍
  • 0083_Remove_Duplicates_from_Sorted_List
    • 思路1 遍历
  • 0084_Largest_Rectangle_in_Histogram
    • 思路1 暴力枚举
  • 0085_Maximal_Rectangle
    • 思路1 dp
  • 0086_Partition_List
    • 思路1 遍历分开,尾接法建两个链表,再连起来
  • 0087_Scramble_String
    • 思路1 递归
  • 0088_Merge_Sorted_Array
    • 思路1 归并排序
  • 0090_Subsets_II
    • 思路1 回溯 dfs
  • 0091_Decode_Ways
    • Solution 1 dp
  • 0092_Reverse_Linked_List_II
    • 思路1 反转链表,再拼接
  • 0093_Restore_IP_Addresses
    • 思路1 暴力枚举
  • 0094_Binary_Tree_Inorder_Traversal
    • slt
  • 0095_Unique_Binary_Search_Trees_II
    • 思路1 递归建树
  • 0096_Unique_Binary_Search_Trees
    • 思路1 dp
  • 0097_Interleaving_String
    • 思路1 dp
  • 0098_Validate_Binary_Search_Tree
    • 思路1 BST中序遍历结果递增
  • 0099_Recover_Binary_Search_Tree
    • 思路1 中序遍历记录错误节点
  • 0100_Same_Tree
    • 思路1 递归检查
  • 0101_Symmetric_Tree
    • 思路1 递归
  • 0102_Binary_Tree_Level_Order_Traversal
    • 思路1 利用栈
  • 0103_Binary_Tree_Zigzag_Level_Order_Traversal
    • 思路1
  • 0104_Maximum_Depth_of_Binary_Tree
    • 思路1 dfs
  • 0105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal
    • 思路1
  • 0106_Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal
    • 思路1
  • 0107_Binary_Tree_Level_Order_Traversal_II
    • 思路1
  • 0108_Convert_Sorted_Array_to_Binary_Search_Tree
    • 思路1
  • 0109_Convert_Sorted_List_to_Binary_Search_Tree
    • 思路1 用快慢指针法找到中点,再递归建树
  • 0110_Balanced_Binary_Tree
    • 思路1 递归
  • 0111_Minimum_Depth_of_Binary_Tree
    • 思路1 dfs
  • 0112_Path_Sum
    • 思路1 递归
  • 0113_Path_Sum_II
    • 思路1 dfs
  • 0114_Flatten_Binary_Tree_to_Linked_List
    • 思路1
  • 0115_Distinct_Subsequences
    • 思路1 dp
  • 0116_Populating_Next_Right_Pointers_in_Each_Node
    • 思路1 前序遍历
  • 0117_Populating_Next_Right_Pointers_in_Each_Node_II
    • 思路1 层序遍历
  • 0118_Pascal's_Triangle
    • 思路1 按数学方法添加
  • 0119_Pascal's_Triangle_II
    • slt
  • 0120_Triangle
    • 思路1 bottom-up dp
  • 0121_Best_Time_to_Buy_and_Sell_Stock
    • slt
  • 0122_Best_Time_to_Buy_and_Sell_Stock_II
    • 思路1
  • 0123_Best_Time_to_Buy_and_Sell_Stock_III
    • 思路1
  • 0124_Binary_Tree_Maximum_Path_Sum
    • 思路1 递归
  • 0125_Valid_Palindrome
    • 思路1 左右检查
  • 0126_Word_Ladder_II
    • 思路1 BFS
  • 0127_Word_Ladder
    • 思路1
  • 0128_Longest_Consecutive_Sequence
    • 思路1
  • 0129_Sum_Root_to_Leaf_Numbers
    • 思路1 dfs
  • 0130_Surrounded_Regions
    • 思路1
  • 0132_Palindrome_Partitioning_II
    • 思路1 dp
  • 0133_Clone_Graph
    • 思路1 递归dfs
  • 0134_Gas_Station
    • 思路1 一次遍历法
  • 0135_Candy
    • Solution1 greedy
  • 0136_Single_Number
    • 思路1 XOR
  • 0137_Single_Number_II
    • slt
  • 0138_Copy_List_with_Random_Pointer
    • 思路1 有丝分裂法,原地复制再分裂
  • 0139_Word_Break
    • Solution 1 dp
  • 0141_Linked_List_Cycle
    • Solution1 快慢指针
  • 0142_Linked_List_Cycle_II
    • Solution1 快慢双指针
  • 0144_Binary_Tree_Preorder_Traversal
    • 思路1 利用栈,非递归
  • 0145_Binary_Tree_Postorder_Traversal
    • Solution 1 迭代
  • 0146_LRU_Cache
    • 思路1 利用链表
  • 0147_Insertion_Sort_List
    • 思路1 插入排序
  • 0148_Sort_List
    • slt
  • 0149_Max_Points_on_a_Line
    • Solution1 暴力枚举
  • 0150_Evaluate_Reverse_Polish_Notation
    • 思路1 栈
  • 0151_Reverse_Words_in_a_String
    • 思路1
  • 0152_Maximum_Product_Subarray
    • 思路1 遍历一遍,同时记录最大和最小值
  • 0153_Find_Minimum_in_Rotated_Sorted_Array
    • 思路1 二分
  • 0154_Find_Minimum_in_Rotated_Sorted_Array_II
    • 思路1 二分
  • 0155_Min_Stack
    • 思路1
  • 0157_Read_N_Characters_Given_Read4
    • Solution1 直接循环调用
  • 0159_Longest_Substring_with_At_Most_Two_Distinct_Characters
    • 思路1 滑动窗口 + 哈希表
  • 0160_Intersection_of_Two_Linked_Lists
    • 思路1 双指针循环相遇
  • 0162_Find_Peak_Element
    • Solution 1 bisearch
  • 0163_Missing_Ranges
    • Solution1 遍历
  • 0164_Maximum_Gap
    • 思路1 桶
  • 0165_Compare_Version_Numbers
    • Solution1 遍历 + 模拟
  • 0166_Fraction_to_Recurring_Decimal
    • 思路1
  • 0167_Two_Sum_II_-_Input_array_is_sorted
    • slt
  • 0168_Excel_Sheet_Column_Title
    • 思路1 不断取余
  • 0169_Majority_Element
    • 思路1 摩尔投票法
  • 0170_Two_Sum_III_-_Data_structure_design
    • 思路1 hash 和 two sum 1 类似
  • 0171_Excel_Sheet_Column_Number
    • Solution1
  • 0172_Factorial_Trailing_Zeroes
    • 思路1 数学方法
  • 0173_Binary_Search_Tree_Iterator
    • 思路1 迭代中序遍历
  • 0175_Combine_Two_Tables
    • 思路1 直接用left join
  • 0176_Second_Highest_Salary
    • Solution 1 use max
  • 0177_Nth_Highest_Salary
    • Solution 1 Directly Single Table Query
  • 0178_Rank_Scores
    • slt
  • 0179_Largest_Number
    • 思路1 自定义排序
  • 0180_Consecutive_Numbers
    • Solution 1 三表联结
  • 0181_Employees_Earning_More_Than_Their_Managers
    • 思路1 使用 JOIN
  • 0182_Duplicate_Emails
    • 思路1 使用GROUP BY
  • 0183_Customers_Who_Never_Order
    • slt
  • 0184_Department_Highest_Salary
    • 思路1
  • 0185_Department_Top_Three_Salaries
    • Solution 1
  • 0187_Repeated_DNA_Sequences
    • Solution 1 hash map
  • 0188_Best_Time_to_Buy_and_Sell_Stock_IV
    • Solution1 DP
  • 0189_Rotate_Array
    • 思路1
  • 0190_Reverse_Bits
    • 思路1 直接把每位取出来放到一个list里,再反转构建结果
  • 0191_Number_of_1_Bits
    • 思路1 遍历数1
  • 0196_Delete_Duplicate_Emails
    • 思路1
  • 0197_Rising_Temperature
    • Solution 1 JOIN
  • 0198_House_Robber
    • 思路1 dp
  • 0199_Binary_Tree_Right_Side_View
    • 思路1
  • 0200_Number_of_Islands
    • 思路1 dfs标记岛屿
  • 0201_Bitwise_AND_of_Numbers_Range
    • 思路1
  • 0202_Happy_Number
    • 思路1 快慢
  • 0203_Remove_Linked_List_Elements
    • Solution1 遍历
  • 0204_Count_Primes
    • slt
  • 0205_Isomorphic_Strings
    • Solution1
  • 0206_Reverse_Linked_List
    • slt
  • 0207_Course_Schedule
    • 思路1 拓扑排序,队列实现
  • 0208_Implement_Trie_(Prefix_Tree)
    • 思路1
  • 0210_Course_Schedule_II
    • 思路1 topolotical sort
  • 0211_Add_and_Search_Word_-_Data_structure_design
    • Solution 1 Trie
  • 0213_House_Robber_II
    • 思路1 dp
  • 0215_Kth_Largest_Element_in_an_Array
    • 思路1 利用快排的partition
  • 0217_Contains_Duplicate
    • 思路1 hash
  • 0218_The_Skyline_Problem
    • Solution1 扫描线法
  • 0219_Contains_Duplicate_II
    • Solution1 hash
  • 0220_Contains_Duplicate_III
    • 思路1
  • 0221_Maximal_Square
    • 思路1 dp
  • 0222_Count_Complete_Tree_Nodes
    • 思路1 遍历,直接数每个结点
  • 0223_Rectangle_Area
    • 思路1
  • 0224_Basic_Calculator
    • Solution1 stack
  • 0225_Implement_Stack_using_Queues
    • 思路1 单队列实现
  • 0226_Invert_Binary_Tree
    • Solution1 dfs 后序遍历
  • 0227_Basic_Calculator_II
    • Solution1 stack
  • 0228_Summary_Ranges
    • Solution1 遍历 数学模拟
  • 0229_Majority_Element_II
    • Solution 1 Boyer-Moore Algorithm
  • 0231_Power_of_Two
    • slt
  • 0232_Implement_Queue_using_Stacks
    • 思路1 两个栈来倒顺序
  • 0233_Number_of_Digit_One
    • 思路1 找规律 + 暴力
  • 0234_Palindrome_Linked_List
    • Solution 1
  • 0235_Lowest_Common_Ancestor_of_a_Binary_Search_Tree
    • Solution1 递归检查
  • 0236_Lowest_Common_Ancestor_of_a_Binary_Tree
    • Solution 1 DFS
  • 0237_Delete_Node_in_a_Linked_List
    • Solution 1 copy value of next node
  • 0239_Sliding_Window_Maximum
    • 思路1
  • 0240_Search_a_2D_Matrix_II
    • Solution 1 Z-search
  • 0242_Valid_Anagram
    • Solution1 hash map
  • 0243_Shortest_Word_Distance
    • Solution1 遍历一次,记录索引
  • 0244_Shortest_Word_Distance_II
    • 思路1
  • 0246_Strobogrammatic_Number
    • 思路1 hash
  • 0251_Flatten_2D_Vector
    • 思路1 在初始化的时候把2D merge成1D
  • 0252_Meeting_Rooms
    • 思路1 按第一个元素排序,并判断有没有重叠
  • 0253_Meeting_Rooms_II
    • 思路1 min heap
  • 0256_Paint_House
    • 思路1 dp
  • 0257_Binary_Tree_Paths
    • Solution1 dfs
  • 0258_Add_Digits
    • Solution1 模拟
  • 0260_Single_Number_III
    • slt
  • 0261_Graph_Valid_Tree
    • 思路1 dfs
  • 0262_Trips_and_Users
    • Solution 1
  • 0263_Ugly_Number
    • Solution1 数学方法
  • 0264_Ugly_Number_II
    • 思路1 dp 三指针法
  • 0266_Palindrome_Permutation
    • Solution1 hash
  • 0268_Missing_Number
    • Solution1 数学方法
  • 0270_Closest_Binary_Search_Tree_Value
    • Solution1 二分查找
  • 0273_Integer_to_English_Words
    • Solution 1 simulation
  • 0274_H-Index
    • slt
  • 0276_Paint_Fence
    • 思路1 dp
  • 0279_Perfect_Squares
    • 思路1 dp
  • 0283_Move_Zeroes
    • slt
  • 0289_Game_of_Life
    • 思路1 用第二位存储下一阶段的状态
  • 0290_Word_Pattern
    • 思路1 hash
  • 0293_Flip_Game
    • Solution1 遍历
  • 0295_Find_Median_from_Data_Stream
    • Solution1 优先队列
  • 0299_Bulls_and_Cows
    • Solution 1 emulate + hash
  • 0300_Longest_Increasing_Subsequence
    • Solution 1 DP
  • 0301_Remove_Invalid_Parentheses
    • Solution1 DFS
  • 0303_Range_Sum_Query_-_Immutable
    • Solution1 Pre sum
  • 0304_Range_Sum_Query_2D_-_Immutable
    • Solution1 Presum
  • 0309_Best_Time_to_Buy_and_Sell_Stock_with_Cooldown
    • Solution 1 DP + state machine
  • 0310_Minimum_Height_Trees
    • 思路1 dfs 剥洋葱
  • 0313_Super_Ugly_Number
    • 思路1 DP
  • 0318_Maximum_Product_of_Word_Lengths
    • Solution 1 brute force simulation
  • 0319_Bulb_Switcher
    • Solution 1 math
  • 0321_Create_Maximum_Number
    • 思路1
  • 0322_Coin_Change
    • Solution1 dp
  • 0323_Number_of_Connected_Components_in_an_Undirected_Graph
    • 思路1 并查集
  • 0326_Power_of_Three
    • Solution1 数学方法
  • 0328_Odd_Even_Linked_List
    • 思路1 双指针
  • 0331_Verify_Preorder_Serialization_of_a_Binary_Tree
    • Solution1 计算出度和入度
  • 0332_Reconstruct_Itinerary
    • 思路1 dfs
  • 0335_Self_Crossing
    • Solution 1 by cases
  • 0338_Counting_Bits
    • Solution1
  • 0340_Longest_Substring_with_At_Most_K_Distinct_Characters
    • Solution1 sliding window + hash table
  • 0341_Flatten_Nested_List_Iterator
    • Solution1 DFS + 遞歸
  • 0342_Power_of_Four
    • Solution1 遍历
  • 0343_Integer_Break
    • slt
  • 0344_Reverse_String
    • 思路1 直接左右对换反转
  • 0345_Reverse_Vowels_of_a_String
    • Solution 1 遍历
  • 0347_Top_K_Frequent_Elements
    • 思路1 利用堆
  • 0349_Intersection_of_Two_Arrays
    • Solution 1 hash
  • 0350_Intersection_of_Two_Arrays_II
    • 思路1 hash
  • 0352_Data_Stream_as_Disjoint_Intervals
    • Solution 1 binary search + simulate
  • 0354_Russian_Doll_Envelopes
    • Solution1 DP + Sort
  • 0355_Design_Twitter
    • 思路1 记录每个tweid的时间。get的时候按时间归并
  • 0359_Logger_Rate_Limiter
    • Solution1 hash
  • 0367_Valid_Perfect_Square
    • slt
  • 0371_Sum_of_Two_Integers
    • Solution1 bit operation
  • 0373_Find_K_Pairs_with_Smallest_Sums
    • 思路1 暴力枚举所有pair,排序后,返回前k个
  • 0375_Guess_Number_Higher_or_Lower_II
    • Solution 1 DP
  • 0376_Wiggle_Subsequence
    • 思路1
  • 0378_Kth_Smallest_Element_in_a_Sorted_Matrix
    • 思路1 矩阵二分查找
  • 0381_Insert_Delete_GetRandom_O(1)_-_Duplicates_allowed
    • 思路1
  • 0382_Linked_List_Random_Node
    • Solution 1 Reservoir Sampling
  • 0383_Ransom_Note
    • Solution1 hash 表统计字符个数
  • 0384_Shuffle_an_Array
    • Solution 1 Shuffle Simulation
  • 0387_First_Unique_Character_in_a_String
    • 思路1 hash
  • 0389_Find_the_Difference
    • 思路1 hash
  • 0391_Perfect_Rectangle
    • Solution 1 geometry + hash
  • 0392_Is_Subsequence
    • 思路1
  • 0395_Longest_Substring_with_At_Least_K_Repeating_Characters
    • Solution1 Split and conquer
  • 0397_Integer_Replacement
    • Solution 1 bit + greedy
  • 0399_Evaluate_Division
    • 思路1 dfs
  • 0401_Binary_Watch
    • Solution1 遍历时间
  • 0402_Remove_K_Digits
    • 思路1
  • 0403_Frog_Jump
    • Solution1 dfs + cache
  • 0404_Sum_of_Left_Leaves
    • Solution1 dfs
  • 0406_Queue_Reconstruction_by_Height
    • Solution1 greedy
  • 0407_Trapping_Rain_Water_II
    • Solution 1 min heap
  • 0408_Valid_Word_Abbreviation
    • Solution1 遍历
  • 0412_Fizz_Buzz
    • Solution 1 traverse
  • 0413_Arithmetic_Slices
    • slt
  • 0415_Add_Strings
    • Solution 1 simulation 10-based add
  • 0416_Partition_Equal_Subset_Sum
    • Solution 1 dp
  • 0421_Maximum_XOR_of_Two_Numbers_in_an_Array
    • Solution1 位运算 + Trie
  • 0424_Longest_Repeating_Character_Replacement
    • 思路1 sliding window
  • 0434_Number_of_Segments_in_a_String
    • Solution1 遍历 直接统计
  • 0435_Non-overlapping_Intervals
    • 思路1 贪心
  • 0437_Path_Sum_III
    • Solution 1 DFS
  • 0441_Arranging_Coins
    • Solution1 模拟
  • 0443_String_Compression
    • Solution1 双指针模拟
  • 0444_Sequence_Reconstruction
    • slt
  • 0445_Add_Two_Numbers_II
    • 思路1 利用stack
  • 0446_Arithmetic_Slices_II_-_Subsequence
    • Solution1 dp
  • 0447_Number_of_Boomerangs
    • slt
  • 0448_Find_All_Numbers_Disappeared_in_an_Array
    • Solution1 hash - operate on original array, mapping number to index
  • 0450_Delete_Node_in_a_BST
    • Solution 1 dfs delete
  • 0451_Sort_Characters_By_Frequency
    • 思路1 大顶堆
  • 0452_Minimum_Number_of_Arrows_to_Burst_Balloons
    • 思路1 贪心
  • 0453_Minimum_Moves_to_Equal_Array_Elements
    • Solution 1 math
  • 0454_4Sum_II
    • 思路1 hash
  • 0455_Assign_Cookies
    • Solution1 greedy
  • 0456_132_Pattern
    • Solution1 單調棧
  • 0458_Poor_Pigs
    • Solution 1 转化为 k 进制问题
  • 0459_Repeated_Substring_Pattern
    • Solution1
  • 0460_LFU_Cache
    • 思路1 hash table + 二叉平衡搜索树
  • 0461_Hamming_Distance
    • Solution1 异或
  • 0463_Island_Perimeter
    • 思路1 dfs
  • 0474_Ones_and_Zeroes
    • Solution 1 DP
  • 0476_Number_Complement
    • Solution 1 Traverse
  • 0477_Total_Hamming_Distance
    • Solution1 乘法原理
  • 0480_Sliding_Window_Median
    • 思路1 双堆 - 双堆对顶
  • 0483_Smallest_Good_Base
    • Solution1 二分 + 模拟
  • 0485_Max_Consecutive_Ones
    • Solution1 Use start to remember start of ones
  • 0488_Zuma_Game
    • Solution 1 DFS with memoization for optimization
  • 0492_Construct_the_Rectangle
    • Solution1 枚举
  • 0493_Reverse_Pairs
    • 思路1 分治。利用归并排序的思路
  • 0494_Target_Sum
    • Solution1 DFS + cache
  • 0495_Teemo_Attacking
    • Solution 1 traverse + simulate
  • 0496_Next_Greater_Element_I
    • Solution 1 Monotone Stack
  • 0501_Find_Mode_in_Binary_Search_Tree
    • Solution1 hash + dfs统计 + 遍历
  • 0502_IPO
    • Solution 1 贪心,排序 + 大顶堆
  • 0503_Next_Greater_Element_II
    • Solution1 单调栈
  • 0504_Base_7
    • Solution 1 divide and mod
  • 0506_Relative_Ranks
    • Solution 1 hash and sort
  • 0509_Fibonacci_Number
    • 思路1 递归
  • 0511_Game_Play_Analysis_I
    • Solution 1
  • 0512_Game_Play_Analysis_II
    • Solution 1
  • 0513_Find_Bottom_Left_Tree_Value
    • Solution 1 level order (dfs)
  • 0514_Freedom_Trail
    • 思路1
  • 0516_Longest_Palindromic_Subsequence
    • slt
  • 0518_Coin_Change_2
    • Solution 1 DP
  • 0520_Detect_Capital
    • Solution1 遍历统计
  • 0521_Longest_Uncommon_Subsequence_I
    • Solution1 规律法
  • 0523_Continuous_Subarray_Sum
    • Solution1 前缀和 + hash + 同余
  • 0524_Longest_Word_in_Dictionary_through_Deleting
    • Solution 1 双指针检查 subsequence
  • 0525_Contiguous_Array
    • Solution1 hash
  • 0526_Beautiful_Arrangement
    • Solution1 回溯
  • 0528_Random_Pick_with_Weight
    • Solution1 前缀和 + 二分查找
  • 0530_Minimum_Absolute_Difference_in_BST
    • Solution1 中序遍历
  • 0534_Game_Play_Analysis_III
    • Solution 1
  • 0538_Convert_BST_to_Greater_Tree
    • Solution 1 right-mid-left traverse
  • 0540_Single_Element_in_a_Sorted_Array
    • Solution 1 二分
  • 0541_Reverse_String_II
    • Solution 1 遍历
  • 0542_01_Matrix
    • 思路1 dp
  • 0543_Diameter_of_Binary_Tree
    • Solution1 dfs 获取高度
  • 0547_Number_of_Provinces
    • 思路1 并查集
  • 0550_Game_Play_Analysis_IV
    • 思路1
  • 0551_Student_Attendance_Record_I
    • Solution1 遍历模拟
  • 0552_Student_Attendance_Record_II
    • Solution1 DP
  • 0556_Next_Greater_Element_III
    • 思路1 利用单调栈
  • 0559_Maximum_Depth_of_N-ary_Tree
    • Solution1 dfs
  • 0560_Subarray_Sum_Equals_K
    • 思路1 前缀和 + hash
  • 0561_Array_Partition_I
    • Solution1 Sort
  • 0563_Binary_Tree_Tilt
    • Solution1 dfs
  • 0566_Reshape_the_Matrix
    • Solution1 Traverse
  • 0567_Permutation_in_String
    • 思路1 滑动窗口 + hash
  • 0570_Managers_with_at_Least_5_Direct_Reports
    • 思路1
  • 0572_Subtree_of_Another_Tree
    • Solution1 preorder dfs
  • 0574_Winning_Candidate
    • slt
  • 0575_Distribute_Candies
    • Solution 1 hash
  • 0577_Employee_Bonus
    • 思路1
  • 0578_Get_Highest_Answer_Rate_Question
    • 思路1
  • 0580_Count_Student_Number_in_Departments
    • 思路1
  • 0581_Shortest_Unsorted_Continuous_Subarray
    • Solution1 贪心 + 双指针
  • 0583_Delete_Operation_for_Two_Strings
    • Solution1 DP
  • 0584_Find_Customer_Referee
    • 思路1
  • 0585_Investments_in_2016
    • 思路1 利用子查询
  • 0586_Customer_Placing_the_Largest_Number_of_Orders
    • 思路1
  • 0595_Big_Countries
    • 思路1
  • 0596_Classes_More_Than_5_Students
    • 思路1
  • 0597_Friend_Requests_I:_Overall_Acceptance_Rate
    • 思路1
  • 0602_Friend_Requests_II:_Who_Has_the_Most_Friends
    • 思路1 使用UNION ALL
  • 0603_Consecutive_Available_Seats
    • 思路1
  • 0605_Can_Place_Flowers
    • Solution1 greedy
  • 0607_Sales_Person
    • 思路1
  • 0608_Tree_Node
    • 思路1 left join + case when
  • 0610_Triangle_Judgement
    • 思路1
  • 0611_Valid_Triangle_Number
    • Solution1 双指针
  • 0612_Shortest_Distance_in_a_Plane
    • 思路1 JOIN计算每两点之间的距离
  • 0613_Shortest_Distance_in_a_Line
    • 思路1
  • 0614_Second_Degree_Follower
    • 思路1
  • 0617_Merge_Two_Binary_Trees
    • Solution 1 pre order dfs
  • 0619_Biggest_Single_Number
    • 思路1
  • 0620_Not_Boring_Movies
    • 思路1
  • 0626_Exchange_Seats
    • 思路1
  • 0627_Swap_Salary
    • 思路1
  • 0629_K_Inverse_Pairs_Array
    • Solution 1 DP + presum
  • 0633_Sum_of_Square_Numbers
    • Solution1 two-pointers
  • 0637_Average_of_Levels_in_Binary_Tree
    • Solution 1 bfs
  • 0639_Decode_Ways_II
    • Solution1 dp + by cases
  • 0643_Maximum_Average_Subarray_I
    • slt
  • 0646_Maximum_Length_of_Pair_Chain
    • Solution 1 DP
  • 0649_Dota2_Senate
    • 思路1 贪心,用队列来模拟投票
  • 0650_2_Keys_Keyboard
    • Solution 1 dp
  • 0653_Two_Sum_IV_-_Input_is_a_BST
    • Solution 1 in-order dfs + hash
  • 0659_Split_Array_into_Consecutive_Subsequences
    • 思路1 哈希表 + 最小堆
  • 0661_Image_Smoother
    • Solution 1 traverse + simulation
  • 0664_Strange_Printer
    • Solution1 DP
  • 0665_Non-decreasing_Array
    • 思路1 贪心
  • 0669_Trim_a_Binary_Search_Tree
    • Solution 1 dfs + BST 性质
  • 0671_Second_Minimum_Node_In_a_Binary_Tree
    • Solution1 dfs
  • 0680_Valid_Palindrome_II
    • Solution1 双指针
  • 0684_Redundant_Connection
    • 思路1 使用并查集
  • 0692_Top_K_Frequent_Words
    • Solution1 hash table + priority queue
  • 0697_Degree_of_an_Array
    • Solution1 Hash
  • 0703_Kth_Largest_Element_in_a_Stream
    • 思路1 优先队列
  • 0704_Binary_Search
    • 思路1 binary search
  • 0714_Best_Time_to_Buy_and_Sell_Stock_with_Transaction_Fee
    • 思路1 dp
  • 0724_Find_Pivot_Index
    • 思路1 前缀和
  • 0725_Split_Linked_List_in_Parts
    • Solution1 simulation
  • 0726_Number_of_Atoms
    • Solution1 stk + 从后往前,一次遍历
  • 0738_Monotone_Increasing_Digits
    • 思路1 贪心
  • 0740_Delete_and_Earn
    • Solution1 dp
  • 0743_Network_Delay_Time
    • Solution1 Dijkstra + 邻接矩阵
  • 0746_Min_Cost_Climbing_Stairs
    • 思路1 dp
  • 0765_Couples_Holding_Hands
    • Solution1 Greedy
  • 0766_Toeplitz_Matrix
    • Solution1 Traverse
  • 0767_Reorganize_String
    • 思路1 贪心法+最大堆
  • 0783_Minimum_Distance_Between_BST_Nodes
    • Solution1 中序遍历
  • 0785_Is_Graph_Bipartite?
    • Solution 1 BFS + 染色法
  • 0786_K-th_Smallest_Prime_Fraction
    • Solution 1 priority queue
  • 0787_Cheapest_Flights_Within_K_Stops
    • Solution1 DP
  • 0789_Escape_The_Ghosts
    • Solution1 贪心 + 曼哈顿距离
  • 0797_All_Paths_From_Source_to_Target
    • Solution1 DFS
  • 0802_Find_Eventual_Safe_States
    • Solution1 拓扑排序 + 反向图
  • 0815_Bus_Routes
    • Solution1 BFS
  • 0820_Short_Encoding_of_Words
    • 思路1 用一个set存储后缀
  • 0830_Positions_of_Large_Groups
    • 思路1 一次遍历,双指针
  • 0832_Flipping_an_Image
    • Solution1 Simulation
  • 0842_Split_Array_into_Fibonacci_Sequence
    • 思路1 回溯
  • 0847_Shortest_Path_Visiting_All_Nodes
    • Solution1 BFS
  • 0852_Peak_Index_in_a_Mountain_Array
    • Solution1 遍历
  • 0859_Buddy_Strings
    • Solution 1 simulation
  • 0860_Lemonade_Change
    • 思路1 一次遍历,记录5和10的个数
  • 0861_Score_After_Flipping_Matrix
    • 思路1 贪心
  • 0863_All_Nodes_Distance_K_in_Binary_Tree
    • Solution1 建图 + BFS
  • 0867_Transpose_Matrix
    • Solution1 Traverse
  • 0869_Reordered_Power_of_2
    • Solution 1 hash
  • 0872_Leaf-Similar_Trees
    • Solution1 Traverse
  • 0876_Middle_of_the_Linked_List
    • 思路1 快慢指针
  • 0877_Stone_Game
    • Solution1 DP
  • 0879_Profitable_Schemes
    • Solution1 DP
  • 0881_Boats_to_Save_People
    • Solution1 双指针 + 贪心
  • 0882_Reachable_Nodes_In_Subdivided_Graph
    • 同239
  • 0887_Super_Egg_Drop
    • 思路1 dp 逆向思维
  • 0888_Fair_Candy_Swap
    • 思路1 hash
  • 0889_Construct_Binary_Tree_from_Preorder_and_Postorder_Traversal
    • Solution 1 from root to leaf build tree
  • 0892_Surface_Area_of_3D_Shapes
    • 思路1
  • 0897_Increasing_Order_Search_Tree
    • Solution 1 in-order dfs
  • 0912_Sort_an_Array
    • 思路1 快排
  • 0914_X_of_a_Kind_in_a_Deck_of_Cards
    • 思路1 统计各个数出现的次数,然后求次数之间是否存在公约数
  • 0922_Sort_Array_By_Parity_II
    • 思路1 两次遍历
  • 0930_Binary_Subarrays_With_Sum
    • Solution1 pre sum + hash
  • 0938_Range_Sum_of_BST
    • Solution1 pre-order traverse
  • 0941_Valid_Mountain_Array
    • 思路1 遍历一遍
  • 0945_Minimum_Increment_to_Make_Array_Unique
    • 思路1 hash的思想 用一个数字来记录重复出现的数字的个数
  • 0959_Regions_Cut_By_Slashes
    • 思路1 并查集
  • 0973_K_Closest_Points_to_Origin
    • 思路1 暴力计算
  • 0976_Largest_Perimeter_Triangle
    • 思路1
  • 0978_Longest_Turbulent_Subarray
    • 思路1 dp
  • 0981_Time_Based_Key-Value_Store
    • Solution 1 hash map + map
  • 0993_Cousins_in_Binary_Tree
    • Solution1 DFS
  • 0995_Minimum_Number_of_K_Consecutive_Bit_Flips
    • Solution1 Sliding Window
  • 0999_Available_Captures_for_Rook
    • 思路1
  • 1004_Max_Consecutive_Ones_III
    • Solution1 Sliding window
  • 1005_Maximize_Sum_Of_Array_After_K_Negations
    • Solution 1 贪心模拟
  • 1006_Clumsy_Factorial
    • Solution1 stack
  • 1011_Capacity_To_Ship_Packages_Within_D_Days
    • Solution1
  • 1025_Divisor_Game
    • Solution1 数学方法
  • 1030_Matrix_Cells_in_Distance_Order
    • 思路1 bfs
  • 1035_Uncrossed_Lines
    • Solution1 dp
  • 1045_Customers_Who_Bought_All_Products
    • 思路1
  • 1046_Last_Stone_Weight
    • 思路1 最大堆
  • 1049_Last_Stone_Weight_II
    • Solution1 DP
  • 1050_Actors_and_Directors_Who_Cooperated_At_Least_Three_Times
    • 思路1
  • 1052_Grumpy_Bookstore_Owner
    • Solution1 Sliding window
  • 1059_All_Paths_from_Source_Lead_to_Destination
    • Solution1 DFS
  • 1068_Product_Sales_Analysis_I
    • 思路1
  • 1069_Product_Sales_Analysis_II
    • 思路1
  • 1070_Product_Sales_Analysis_III
    • 思路1 利用子查询
  • 1074_Number_of_Submatrices_That_Sum_to_Target
    • Solution1 前缀和 + hash 表优化
  • 1075_Project_Employees_I
    • 思路1
  • 1076_Project_Employees_II
    • 思路1
  • 1077_Project_Employees_III
    • 思路1
  • 1082_Sales_Analysis_I
    • 思路1
  • 1083_Sales_Analysis_II
    • 思路1
  • 1084_Sales_Analysis_III
    • 思路1 用子查询
  • 1098_Unpopular_Books
    • 思路1
  • 1104_Path_In_Zigzag_Labelled_Binary_Tree
    • Solution1 二叉树性质
  • 1107_New_Users_Daily_Count
    • 思路1
  • 1109_Corporate_Flight_Bookings
    • slt
  • 1110_Delete_Nodes_And_Return_Forest
    • Solution 1 DFS + hash
  • 1111_Maximum_Nesting_Depth_of_Two_Valid_Parentheses_Strings
    • 思路1
  • 1112_Highest_Grade_For_Each_Student
    • 思路1
  • 1113_Reported_Posts
    • 思路1
  • 1122_Relative_Sort_Array
    • 思路1 双重循环
  • 1126_Active_Businesses
    • 思路1
  • 1128_Number_of_Equivalent_Domino_Pairs
    • slt
  • 1132_Reported_Posts_II
    • 思路1
  • 1135_Connecting_Cities_With_Minimum_Cost
    • Solution1 Kruskal 算法
  • 1141_User_Activity_for_the_Past_30_Days_I
    • 思路1
  • 1142_User_Activity_for_the_Past_30_Days_II
    • 思路1 使用distinct直接计算
  • 1143_Longest_Common_Subsequence
    • Solution 1 DP
  • 1148_Article_Views_I
    • 思路1
  • 1162_As_Far_from_Land_as_Possible
    • 思路1 BFS
  • 1173_Immediate_Food_Delivery_I
    • 思路1
  • 1178_Number_of_Valid_Words_for_Each_Puzzle
    • slt
  • 1179_Reformat_Department_Table
    • 思路1
  • 1190_Reverse_Substrings_Between_Each_Pair_of_Parentheses
    • Solution1 模拟 + 栈
  • 1202_Smallest_String_With_Swaps
    • 思路1 并查集
  • 1203_Sort_Items_by_Groups_Respecting_Dependencies
    • 思路1 拓扑排序
  • 1207_Unique_Number_of_Occurrences
    • 思路1 map + set
  • 1208_Get_Equal_Substrings_Within_Budget
    • 思路1 滑动窗口
  • 1211_Queries_Quality_and_Percentage
    • 思路1
  • 1218_Longest_Arithmetic_Subsequence_of_Given_Difference
    • Solution 1 DP
  • 1221_Split_a_String_in_Balanced_Strings
    • Solution 1 贪心
  • 1232_Check_If_It_Is_a_Straight_Line
    • 思路1 检查斜率
  • 1241_Number_of_Comments_per_Post
    • 思路1
  • 1251_Average_Selling_Price
    • 思路1
  • 1269_Number_of_Ways_to_Stay_in_the_Same_Place_After_Some_Steps
    • Solution1 DP
  • 1280_Students_and_Examinations
    • 思路1
  • 1294_Weather_Type_in_Each_Country
    • 思路1
  • 1303_Find_the_Team_Size
    • 思路1
  • 1310_XOR_Queries_of_a_Subarray
    • Solution1 前缀和
  • 1322_Ads_Performance
    • 思路1
  • 1327_List_the_Products_Ordered_in_a_Period
    • 思路1
  • 1350_Students_With_Invalid_Departments
    • 思路1
  • 1370_Increasing_Decreasing_String
    • 思路1 桶技术
  • 1378_Replace Employee_ID_With_The_Unique_Identifier
    • 思路1 left join
  • 1418_Display_Table_of_Food_Orders_in_a_Restaurant
    • Solution1 hash
  • 1438_Longest_Continuous_Subarray_With_Absolute_Diff_Less_Than_or_Equal_to_Limit
    • Solution1 Sliding window + Ordered Sequence
  • 1442_Count_Triplets_That_Can_Form_Two_Arrays_of_Equal_XOR
    • Solution1 前缀和 + 暴力
  • 1486_XOR_Operation_in_an_Array
    • Solution1 遍历一遍
  • 1579_Remove_Max_Number_of_Edges_to_Keep_Graph_Fully_Traversable
    • 思路1 并查集
  • 1600_Throne_Inheritance
    • Solution1 字典 + 链表
  • 1603_Design_Parking_System
    • Solution1 hash
  • 1631_Path_With_Minimum_Effort
    • 思路1 dijkstra算法变种
  • 1646_Get_Maximum_in_Generated_Array
    • Solution1 模拟遍历
  • 1711_Count_Good_Meals
    • Solution1 hash
  • 1720_Decode_XORed_Array
    • 思路1 反向异或
  • 1721_Swapping_Nodes_in_a_Linked_List
    • 思路1 双指针
  • 1722_Minimize_Hamming_Distance_After_Swap_Operations
    • 思路1 并查集
  • 1723_Find_Minimum_Time_to_Finish_All_Jobs
    • 思路1 dfs暴力破解 + 剪枝
  • 1734_Decode_XORed_Permutation
    • Solution1 数学模拟
  • 1738_Find_Kth_Largest_XOR_Coordinate_Value
    • Solution1 前缀和 + 最小堆
  • 1744_Can_You_Eat_Your_Favorite_Candy_on_Your_Favorite_Day?
    • Solution1 模拟 + 前缀和
  • 1746_Maximum_Subarray_Sum_After_One_Operation
    • Solution1 DP
  • 1770_Maximum_Score_from_Performing_Multiplication_Operations
    • Solution1 DP
  • 1787_Make_the_XOR_of_All_Segments_Equal_to_Zero
    • Solution1 DP
  • 1833_Maximum_Ice_Cream_Bars
    • Solution1 greedy
  • 1838_Frequency_of_the_Most_Frequent_Element
    • Solution1 前缀和 + 二分
  • 1846_Maximum_Element_After_Decreasing_and_Rearranging
    • Solution1 排序 + 遍历模拟
  • 1877_Minimize_Maximum_Pair_Sum_in_Array
    • Solution1 排序 + 模拟
  • 1893_Check_if_All_the_Integers_in_a_Range_Are_Covered
    • Solution1 贪心
  • 1894_Find_the_Student_that_Will_Replace_the_Chalk
    • Solution1 求模 + 模拟
  • mst01.07_Rotate_Matrix_LCCI
    • 思路1 先上下翻转,再转置
  • mst02.05_Sum_Lists_LCCI
    • 思路1 直接遍历计算
  • mst10.01_Sorted_Merge_LCCI
    • 思路1
  • mst16.15_Master_Mind_LCCI
    • 思路1 双hash
  • mst16.16_Sub_Sort_LCCI
    • 思路1 双指针
  • mst16.17_Contiguous_Sequence_LCCI
    • 思路1 dp
  • mst16.20_T9_LCCI
    • 思路1 hash
  • mst16.21_Sum_Swap_LCCI
    • 思路1 hash
  • mst16.22_Langtons_Ant_LCCI
    • Solution 1 Simulation
  • mst16.24_Pairs_With_Sum_LCCI
    • Solution1 Hash
  • mst17.04_Missing_Number_LCCI
    • Solution1 xor
  • mst17.14_Smallest_K_LCCI
    • Solution1 排序
  • mst17.16_The_Masseuse_LCCI
    • 思路1 dp
  • mst17.21_Volume_of_Histogram_LCCI
    • Solution1
Powered by GitBook
On this page

Was this helpful?

  1. 0097_Interleaving_String

思路1 dp

Previous0097_Interleaving_StringNext0098_Validate_Binary_Search_Tree

Last updated 5 years ago

Was this helpful?

Here is some explanation:

dp[i-1][j-1] means s3 is interleaving at (i+j)th position when s1 is at ith position, and s2 is at jth position. 0th position means empty string.

So

  • if both s1 and s2 is currently empty, s3 is empty too, and it is considered interleaving.

  • If only s1 is empty, then if previous s2 position is interleaving and current s2 position char is equal to s3 current position char, it is considered interleaving. similar idea applies to when s2 is empty.

  • when both s1 and s2 is not empty, then if we arrive i, j from i-1, j, then if i-1,j is already interleaving and i and current s3 position equal, it s interleaving. If we arrive i,j from i, j-1, then if i, j-1 is already interleaving and j and current s3 position equal. it is interleaving.

可以看看这里的方法3

https://leetcode-cn.com/problems/interleaving-string/solution/jiao-cuo-zi-fu-chuan-by-leetcode/