DP solves problems by breaking them into overlapping subproblems and storing results (memoization or tabulation) to avoid recomputation. Use it when a problem has optimal substructure and overlapping subproblems — e.g. knapsack, edit distance, longest common subsequence.
Algorithms· asked at Meta✓ Added to review
JS runs on a single thread with a call stack. Async callbacks go to task queues (macrotasks like setTimeout, microtasks like Promises). The event loop pushes queued callbacks onto the stack only when it is empty, draining all microtasks before the next macrotask.
JavaScript· asked at Amazon✓ Added to review
A deadlock is when processes wait on each other indefinitely. It needs four conditions simultaneously (Coffman): mutual exclusion, hold-and-wait, no preemption, and circular wait. Breaking any one prevents deadlock.
Operating Systems· asked at Generic✓ Added to review
The Global Interpreter Lock allows only one thread to execute Python bytecode at a time, simplifying memory management but limiting CPU-bound multithreading. Use multiprocessing or native extensions for CPU parallelism; threads still help with I/O-bound work.
Python· asked at Microsoft✓ Added to review
Generate a unique short code (base62 of an auto-increment ID or a hash) mapping to the long URL in a key-value/relational store. Add caching (Redis) for hot reads, a redirect service returning 301/302, analytics, and consider sharding + a counter service for scale.
System Design· asked at Amazon✓ Added to review
In a distributed system you can guarantee at most two of Consistency, Availability, and Partition tolerance. Since network partitions are unavoidable, you effectively choose between consistency (CP) and availability (AP) during a partition.
System Design· asked at Meta✓ Added to review
💬
Send Feedback / Bug
Feedback Submitted!
Thank you. Your help keeps Geeky Script running smoothly.