Day 1/30 back to DSA challenge
Source: Dev.to
DSA
- Reviewed notes on DSA.
- Solved the Two Sum problem using a hashmap and the complement technique.
- Instead of storing each element and checking sums, store the complement (
target - current number). - When a number matches a stored complement, return the indices of the two numbers.
- Instead of storing each element and checking sums, store the complement (
Promises
- Discussed asynchronous programming in JavaScript.
- Synchronous execution runs line‑by‑line; a long‑running operation (e.g., an API request) blocks subsequent lines.
- Asynchronous execution allows other code to run while waiting for the operation to complete.
- A callback is a function passed as an argument to be executed later.
- Nested callbacks lead to “callback hell.”
- Promises provide a cleaner way to handle asynchronous operations and avoid callback hell.
So this is what I learned today. I will be much more productive in my next challenge. I Promise! (haha)