Initializing a Javascript DSA marathon thread where l will upload each DSA Problem every day, along with the approach and pattern I used to solve it.
@DilsherJ@020Adhish
Is it possible to kill the same man twice?
Govt of India just proved that it can be done.
Jaswant Khalra was encountered for the second time in 2026.
Probably one of our most disturbing episodes - not just because we had to revisit one of the darkest chapters of Punjab's history - but also because we had to face the harsh reality of why a panic-stricken Modi Govt wanted to block this movie so bad.... (even three decades after what happened to Khalra)
Still - this movie gives us hope - there are people who still want to challenge the darkness.... kudos to @HoneyTrehan@diljitdosanjh@ZEE5India for standing on the right side of history.
//
▶️- https://t.co/3wANuQxk6j
Initializing a Javascript DSA marathon thread where l will upload each DSA Problem every day, along with the approach and pattern I used to solve it.
@DilsherJ@020Adhish
Approach:🧠
1️⃣🌳 Start BFS with the root at level 1
2️⃣📦 Use a queue store [node, level] pairs
3️⃣🗂️ Use a Map to group node values by level
4️⃣🔁 Pop node, add value, push childs w/ level+1
5️⃣➕➗ For each level, sum the values and compute the average
6️⃣📤 Return avg list
@Prathkum Agreed, It just a marketing buzz to take money from investors in the name of AI. Even low-code/no-code tools like servicenow requires real developers to enhance the capabilities of the platform and meet the client requirements.
Approach: 🧠 Time Needed to Buy Tickets
1️⃣ Build queue as [person, tickets] pairs
2️⃣ Start time at 1 ⏱️
3️⃣ Shift front of queue 👈
4️⃣ Decrement their ticket 🎟️
5️⃣ If person==k and ticket==0 → return time 🎯
6️⃣ Else push back if tickets remain 🔁
7️⃣ Repeat until k finishes ✅
Approach: Stack using Queue🧱
1️⃣ Push new element ➡️ Q2
2️⃣ Move everything from Q1 → Q2 🔄
3️⃣ Swap Q1 🔁 Q2 so Q1 holds stack order 📦
4️⃣ Pop/Top read from front of Q1 🎯
5️⃣ Empty = Q1 has no items 🚫📥
Approach: 🧮 Evaluate RPN using a stack:
🔄 Start by iterating through tokens:
1️⃣📥 Push numbers onto a stack.
2️⃣✖️➕➖➗ When an operator appears, pop 2 values.
3️⃣⚙️ Apply the operation (division truncates to 0).
4️⃣📤 Push the result back.
5️⃣🏁 Final stack value = 🎯 answer.