Skip to content

Instantly share code, notes, and snippets.

View NickEU's full-sized avatar
💭
A line of code a day keeps the paranoid schizophrenia away

Nikolajs Korolkovs NickEU

💭
A line of code a day keeps the paranoid schizophrenia away
  • Stockholm, Sweden
View GitHub Profile
@NickEU
NickEU / grokking_to_leetcode.md
Created August 18, 2023 07:51 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

public IProcess<T> FactoryProduceProcessor(string typeName, T data) // typeName=="CompactDisk" ? Then return CompactDisk<T>
{
Type processorType = Type.GetType(typeName);
if (processorType == null || !typeof(IProcess<T>).IsAssignableFrom(processorType))
{
throw new ArgumentException("Invalid typeName");
}
return (IProcess<T>)Activator.CreateInstance(processorType, data);
}
public String jumpSearch() {
String reportSortResult = bubbleSort();
long sortingTime = lastOperationTimer.getElapsed();
String reportSearch = reportSortResult.contains("STOPPED")
? findUsingLinearSearch(false)
: findUsingJumpSearch();
long searchTime = lastOperationTimer.getElapsed();
String reportTotalTime = "Time taken: " + Util.convertMsToMinSec(sortingTime + searchTime) + "\n";
return "Start searching (bubble sort + jump search)...\n" + reportSearch + reportTotalTime
+ reportSortResult + "Searching time: " + Util.convertMsToMinSec(searchTime);