LeetCode対策のメモ

LeetCode練習をはじめたが効率よくやるためには、pythonになれてきたら、大まかなアウトラインを体系的に身につけないとダメそうである。

そこで英語ですが良さそうなブログの記事が

このブログによると

データストラクチャとして知っておかないといけないこと

Dynamic Array
Linked List
Stack & Queue
Hash Tables
Binary Search Tree
Binary Heaps & Priority Queue
Graphs
Trie

アルゴリズムとして知っておかないといけないこと

Bit Manipulation & Numbers — difference btw Unsigned vs signed numbers
Stability in Sorting
Mergesort
Quicksort
Heapsort — Sort it in-place to get O(1) space
Binary Search
Selections — Kth Smallest Elements (Sort, QuickSelect, Mediums of Mediums) — Implement all three ways
Permutations
Subsets
BFS Graph
DFS Graph
Dijkstra’s Algorithm (just learn the idea — no need to implement)
Tree Traversals — BFS, DFS (in-order, pre-order, post-order): Implement Recursive and Iterative
External Sort — No implementation; Just know the concept.
NP-Complete (Video) — Just know the concept
Topological Sort
Detect cycle in an undirected graph
Detect a cycle in a directed graph
Count connected components in a graph
Find strongly connected components in a graph

これらは概説記事を読むなりすれば良いらしい。

その上で以下の課題について練習問題をだいたいどのトピックスも2-3回やっていくのがよいようである。

Implement an ArrayList from scratch
Reverse a linked list
Implement a Stack & a Queue using Array
Implement a HashTable with simple Hashing functions
Implement a Graph using Adjacency List, and then write functions for BFS & DFS.
Write the binary search algorithm both recursively and iteratively
Write the merge sort algorithm
Write the quicksort algorithm
Print binary tree using DFS (in-order, preorder and post order — all three of them) and BFS.
Memorize time & space complexities for common algorithms. Here’s an interesting website.
Implement a trie.
Learn these important bit manipulation tricks.

慣れている人なら数週から数ヶ月、自分のように独学者で初心者の場合は半年くらいかけると良いらしい。

Easy問題を解くとともにデータストラクチャとアルゴリズムの勉強をするのが効率良さそうである。

また上記コンセプトからすると以下Noteよくできている。


この記事が気に入ったらサポートをしてみませんか?