暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

算法学习笔记-15种模式

v587博客 2021-08-24
767

算法学习笔记-15种模式

作者:Fahim ul Haq

来源:https://medium.com/hackernoon/14-patterns-to-ace-any-coding-interview-question-c5bb3357f6ed



滑动窗口



经典题目:

Maximum Sum Subarray of Size K (easy)

Smallest Subarray with a given sum (easy)

Longest Substring with K Distinct Characters (medium)

Fruits into Baskets (medium)

No-repeat Substring (hard)

Longest Substring with Same Letters after Replacement (hard)

Longest Subarray with Ones after Replacement (hard)


双指针



经典题目:

Pair with Target Sum (easy)

Remove Duplicates (easy)

Squaring a Sorted Array (easy)

Triplet Sum to Zero (medium)

Triplet Sum Close to Target (medium)

Triplets with Smaller Sum (medium)

Subarrays with Product Less than a Target (medium)

Dutch National Flag Problem (medium)


快慢指针



经典题目:

LinkedList Cycle (easy)

Start of LinkedList Cycle (medium)

Happy Number (medium)

Middle of the LinkedList (easy)


区间合并



经典题目:

Merge Intervals (medium)

Insert Interval (medium)

Intervals Intersection (medium)

Conflicting Appointments (medium)


循环排序



经典题目:

Cyclic Sort (easy)

Find the Missing Number (easy)

Find all Missing Numbers (easy)

Find the Duplicate Number (easy)

Find all Duplicate Numbers (easy)


原地反转链表



经典题目:

Reverse a LinkedList (easy)

Reverse a Sub-list (medium)

Reverse every K-element Sub-list (medium)


树上的BFS



经典题目:

Binary Tree Level Order Traversal (easy)

Reverse Level Order Traversal (easy)

Zigzag Traversal (medium)

Level Averages in a Binary Tree (easy)

Minimum Depth of a Binary Tree (easy)

Level Order Successor (easy)

Connect Level Order Siblings (medium)


树上的DFS



经典题目:

Binary Tree Path Sum (easy)

All Paths for a Sum (medium)

Sum of Path Numbers (medium)

Path With Given Sequence (medium)

Count Paths for a Sum (medium)


双堆


经典题目:

Find the Median of a Number Stream (medium)

Sliding Window Median (hard)

Maximize Capital (hard)


子集


经典题目:

Subsets (easy)

Subsets With Duplicates (easy)

Permutations (medium)

String Permutations by changing case (medium)

Balanced Parentheses (hard)

Unique Generalized Abbreviations (hard)


变种二分搜索



经典题目:

Order-agnostic Binary Search (easy)

Ceiling of a Number (medium)

Next Letter (medium)

Number Range (medium)

Search in a Sorted Infinite Array (medium)

Minimum Difference Element (medium)

Bitonic Array Maximum (easy)


最大前K个元素



经典题目:

Top ‘K’ Numbers (easy)

Kth Smallest Number (easy)

‘K’ Closest Points to the Origin (easy)

Connect Ropes (easy)

Top ‘K’ Frequent Numbers (medium)

Frequency Sort (medium)

Kth Largest Number in a Stream (medium)

‘K’ Closest Numbers (medium)

Maximum Distinct Elements (medium)

Sum of Elements (medium)

Rearrange String (hard)


K-路归并



经典题目:

Merge K Sorted Lists (medium)

Kth Smallest Number in M Sorted Lists (Medium)

Kth Smallest Number in a Sorted Matrix (Hard)

Smallest Number Range (Hard)


拓扑排序



任务执行顺序安排(中等)

树的最小高度(困难)


按位异或




Single Number (easy)

Two Single Numbers (medium)

Complement of Base 10 Number (medium)

动态规划



0/1 Knapsack (medium)

Equal Subset Sum Partition (medium)

Subset Sum (medium)

Minimum Subset Sum Difference (hard)  


模式1:0/1背包

0/1背包

相等子集总分区

子集总和

最小子集总和差

子集总数的计数

目标总和


模式2:无限背包

无限背包

杆切割

硬币找零

最小硬币找零

最大切带

模式3:斐波那契数


斐波那契数

楼梯

数量因素

最小跳到终点

最少跳带费用

家贼


模式4:回文子序列

最长回文序列

最长回文子串

回文子串数

字符串中的最小删除使其成为回文

回文分区


模式5:最长的公共子串

最长的公共子串

最长公共子序列

将字符串转换为另一个字符串的最小删除和插入次数

最长递增子序列

最大总和增加子序列

最短的通用超序列

使序列排序的最小删除

最长重复子序列

子序列模式匹配

最长的双子序列

最长的交替子序列

编辑距离

字符串交织


算法模式培训课程:

https://www.educative.io/courses/grokking-the-coding-interview?aff=K7qB

java面试中的算法培训课程:

https://www.educative.io/courses/algorithms-coding-interviews-java


文章转载自v587博客,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论