0

LEETCODE PATTERNS

 2 years ago
source link: https://blog.feelyou.top/posts/4273093055.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

经历了面试才体会到不论头多硬都得好好刷leetcode。
在reddit上学习到的先进科学文化知识,不错的网站和刷题表格。刷起来,朋友。

leetcode-patterns

tips:

  • 如果输入数组是有序的:二分查找、双指针;
  • 如果要求互换、子集的:回溯;
  • 如果给出:DFS/BFS;
  • 如果给出:DFS/BFS;
  • 如果给一个链表:双指针;
  • 如果禁止递归:栈;
  • 如果必须在原位置解决:交换符合条件的值、存储一个或多个不同值在相同指针;
  • 如果求最大/小 子数组/子集/选项:动态规划;
  • 如果求top/least K items:堆;
  • 如果求公共字符串:Map、前缀树(trie)

  • Map/Set 占用O(1)时间和O(n)空间;

  • 排序 占用O(nlogn)时间和O(1)空间;

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK