Coding Interview Preparation
5.9K subscribers
486 photos
2 videos
114 files
174 links
Coding interview preparation for software engineers

Interview questions, DSA, clean solutions.
Join πŸ‘‰ https://rebrand.ly/bigdatachannels

Buy ads: https://telega.io/c/coding_interview_preparation

DMCA: @disclosure_bds
Contact: @mldatascientist
Download Telegram
πŸ“Š SQL SATURDAY #1 - The Basics, Done Right

Let's start simple but do it properly. Here's our table:


employees
+----+----------+------------+--------+
| id | name | department | salary |
+----+----------+------------+--------+
| 1 | Alice | Engineering| 95000 |
| 2 | Bob | Sales | 62000 |
| 3 | Charlie | Engineering| 105000 |
| 4 | Diana | Marketing | 70000 |
+----+----------+------------+--------+


Question: Find all employees in Engineering earning more than 100,000.

sql
SELECT name, salary
FROM employees
WHERE department = 'Engineering'
AND salary > 100000;


Simple, right? But here's the interview trap:

⚠️ Common pitfall: People forget WHERE runs before SELECT logically, so you can't reference a column alias defined in SELECT inside your WHERE clause.

sql
-- This will ERROR in most databases:
SELECT salary * 1.1 AS new_salary
FROM employees
WHERE new_salary > 100000; -- ❌ new_salary doesn't exist yet here


Fix it by repeating the expression or using a subquery/CTE. We'll get into CTEs in a few weeks πŸ‘€

What's a SQL mistake that tripped you up early on? πŸ˜…
❀6
πŸ•΅οΈ RECRUITER SECRETS #1

Here's something most candidates don't know:

Recruiters usually decide whether to move you forward within the first 30 seconds of reading your resume.

Not because they're lazy - because they're screening 200+ resumes for one role and pattern-matching fast.

What they scan for first:
βœ… Job titles that match seniority level
βœ… Tech stack keywords from the job description
βœ… Quantified impact ("reduced load time by 40%" > "worked on performance")
βœ… No unexplained gaps or job-hopping without context

What kills your chances instantly:
❌ A generic objective statement nobody reads
❌ Walls of text with no visual hierarchy
❌ Listing responsibilities instead of outcomes

Pro tip: Tailor your top 3 bullet points to mirror the exact language in the job posting. ATS systems and human recruiters both respond to it.

Has a recruiter ever given you feedback on your resume? Share it below πŸ‘‡
❀3
🧠 EDUCATIONAL CS #1 - Big O, Explained Without the Jargon

Big O isn't about "how fast is my code." It's about "how does my code's cost grow as the input grows."

Think of it like this:

πŸ“¦ O(1) - Grabbing the first item in a box. Doesn't matter if the box has 10 or 10 million items.

πŸ“¦ O(log n) - Finding a word in a dictionary by flipping to the middle, then the middle of that half, and so on. Doubling the dictionary size only adds one more flip.

πŸ“¦ O(n) - Reading every page of a book once. Twice the pages, twice the time.

πŸ“¦ O(n log n) - Sorting a deck of cards efficiently (merge sort). A bit worse than linear, way better than...

πŸ“¦ O(nΒ²) - Comparing every card in the deck to every other card. Double the deck, quadruple the work.

Here's the part interviewers actually care about: can you identify the complexity of code you didn't write, and can you explain why, not just state the label.

Quick check - what's the time complexity of this?

python
def mystery(arr):
for i in range(len(arr)):
for j in range(i, len(arr)):
print(arr[i], arr[j])


Drop your answer below πŸ‘‡ (hint: it's not quite O(nΒ²))
🧠 7 Golden Rules to Crack Data Science Interviews πŸ§‘β€πŸ’»

1️⃣ Master the Fundamentals
⦁ Be clear on stats, ML algorithms, and probability
⦁ Brush up on SQL, Python, and data wrangling

2️⃣ Know Your Projects Deeply
⦁ Be ready to explain models, metrics, and business impact
⦁ Prepare for follow-up questions

3️⃣ Practice Case Studies & Product Thinking
⦁ Think beyond code - focus on solving real problems
⦁ Show how your solution helps the business

4️⃣ Explain Trade-offs
⦁ Why Random Forest vs. XGBoost?
⦁ Discuss bias-variance, precision-recall, etc.

5️⃣ Be Confident with Metrics
⦁ Accuracy isn’t enough - explain F1-score, ROC, AUC
⦁ Tie metrics to the business goal

6️⃣ Ask Clarifying Questions
⦁ Never rush into an answer
⦁ Clarify objective, constraints, and assumptions

7️⃣ Stay Updated & Curious
⦁ Follow latest tools (like LangChain, LLMs)
⦁ Share your learning journey on GitHub or blogs

@coding_interview_preparation
❀2
Forwarded from Cool GitHub repositories
πŸ’Ό 20 GitHub Repositories to Help You Get Hired

1. coding-interview-university
A complete self-study roadmap originally created to prepare for Google software engineering interviews.

2. awesome-interview-questions
A curated collection of technical interview questions across dozens of programming languages and technologies.

3. system-design-primer
One of the best resources for mastering system design interviews at top tech companies.

4. build-your-own-x
Learn by building your own database, operating system, Git, Docker, Redis, and dozens of other technologies.

5. developer-roadmap
Interactive roadmaps showing exactly what to learn for frontend, backend, DevOps, AI, cybersecurity, and more.

6. project-based-learning
Learn programming by building real projects instead of following endless tutorials.

7. app-ideas
Hundreds of project ideas ranging from beginner to advanced to strengthen your portfolio.

8. public-apis
A massive collection of free APIs you can use to build real-world portfolio projects.

9. free-programming-books
Thousands of free programming books, courses, and learning resources in multiple languages.

10. first-contributions
A step-by-step guide that teaches you how to make your first pull request.

11. frontend-practice
Practice rebuilding real company websites to improve your frontend development skills.

12. Frontend Mentor Challenges
Realistic UI challenges that help you build an employer-ready frontend portfolio.

13. awesome-resume
A professional, ATS-friendly resume template widely used by software engineers.

14. The Algorithms
A huge collection of algorithms and data structures implemented in dozens of programming languages.

15. Tech Interview Handbook
Covers coding interviews, behavioral interviews, resume tips, salary negotiation, and more.

16. awesome
The original Awesome list containing thousands of carefully curated developer resources.

17. realworld
Build the same production-grade application in different frameworks to learn industry architecture.

18. awesome-for-beginners
Find beginner-friendly open source projects to make your first GitHub contributions.

19. awesome-cheatsheets
A collection of programming and DevOps cheat sheets for quick reference during development.

20. Awesome Job Boards
A curated collection of the best tech job boards, including remote, startup, and developer-focused hiring platforms.


πŸ’»Master these repositories, build projects from them, contribute to open source, and you'll have both the skills and portfolio that recruiters actually look for.
❀3
πŸ—οΈ SYSTEM DESIGN MONDAY #1 - The Absolute Basics

Before we design TinyURL, Instagram, or Netflix, let's build the mental model.

Every system design interview starts here:


[Client] --request--> [Server] --query--> [Database]
[Client] <--response-- [Server] <--data---- [Database]


A client (browser, mobile app) sends a request. A server processes it, maybe talks to a database, and sends a response back.

The interview isn't testing whether you know this diagram - it's testing whether you can identify where this breaks down at scale.

πŸ”₯ One server, one database works fine for 100 users.

At 1 million users, that single server becomes a bottleneck. What do you do?

That's the entire arc of system design interviews: start simple, then the interviewer says "now imagine 10x traffic" - and you evolve the design.

Over the coming weeks we'll build up from this exact diagram to full designs of TinyURL, WhatsApp, Instagram, Netflix, Uber, and Google Docs.

For now: if your single server started getting slow under load, what's the FIRST thing you'd check? Drop your answer πŸ‘‡
πŸ› SPOT THE BUG #1
Language: Python

python
def get_average(scores):
total = 0
for score in scores:
total += score
return total / len(scores)

print(get_average([]))


What breaks here? Try to spot it before reading on πŸ‘‡

.
.
.

The bug: ZeroDivisionError when scores is empty. It's an easy edge case to forget under interview pressure, but interviewers plant empty-input tests specifically to see if you check for them.

Fixed version:
python
def get_average(scores):
if not scores:
return 0 # or raise a meaningful exception, depending on requirements
return sum(scores) / len(scores)


πŸ’‘ Takeaway: Before you write a single line of code in an interview, say out loud: "What happens with an empty input? A single element? Negative numbers?" It shows structured thinking, and it catches bugs like this before they exist.
Common File Types Explained
πŸ—£οΈ BEHAVIORAL INTERVIEW #1 - "Tell Me About Yourself"

This question kills more interviews than any coding question ever will. Not because it's hard - because people ramble.

❌ What NOT to do: Recite your entire resume chronologically starting from university.

βœ… What actually works - the "Present, Past, Future" formula:

1️⃣ Present: What you do right now, in one sentence.
2️⃣ Past: How you got here - the 1-2 experiences most relevant to THIS role.
3️⃣ Future: Why you're excited about this specific opportunity.

Example:
"Right now I'm a backend engineer at a fintech startup, focused on building payment infrastructure that processes millions of transactions daily. Before that, I spent three years at [Company] scaling their API from handling thousands to millions of requests, which is actually what got me excited about distributed systems. I'm looking at this role because you're solving similar scaling challenges, but at a size and complexity I haven't tackled yet."

Under 60 seconds. Relevant. Forward-looking.

Try writing your own "Present, Past, Future" answer in the comments - I'll give feedback on a few πŸ‘‡
❀3
⚠️ COMMON INTERVIEW MISTAKE #1 - Jumping Straight Into Code

The single most common thing that turns a "strong hire" into a "no hire": candidates hear the problem and immediately start typing.

Here's what that signals to the interviewer: you don't clarify requirements, you don't think about edge cases, and you might do the same thing on a real production ticket.

βœ… What strong candidates do instead:

1. Repeat the problem back in your own words
2. Ask clarifying questions ("Can the array contain duplicates? Negative numbers? Is it sorted?")
3. State your approach out loud BEFORE writing code
4. Mention the time/space complexity of your plan
5. THEN code

This adds maybe 90 seconds. It makes you look like someone who's shipped real software, not someone doing a LeetCode speedrun.

Have you ever jumped into code too fast and regretted it? Tell us the story πŸ˜…
🎯 CODING CHALLENGE #2 - Valid Parentheses
Difficulty: Easy | Asked at: Microsoft, Meta, Bloomberg

Given a string containing just (, ), {, }, [, ], determine if the input is valid. Brackets must close in the correct order.


Input: "{[()]}" β†’ true
Input: "{[(])}" β†’ false
Input: "(((" β†’ false


πŸ’‘ Hint: What data structure naturally handles "last opened, first closed"?

Solution:
python
def is_valid(s):
stack = []
pairs = {')': '(', ']': '[', '}': '{'}
for char in s:
if char in pairs.values():
stack.append(char)
elif char in pairs:
if not stack or stack.pop() != pairs[char]:
return False
else:
return False
return not stack


Complexity: O(n) time, O(n) space (worst case, all opening brackets).

Common mistake: Forgetting to check if the stack is empty at the very end. "(((" never fails inside the loop - you only catch it because the stack still has unclosed brackets when you finish.

Stacks show up constantly in interviews. Where else have you seen one used? πŸ‘‡
πŸ“„ RESUME ROAST #1

Here's a real-style resume bullet. Before I roast it, tell me what's wrong:

> "Responsible for developing and maintaining web applications using React and Node.js, worked closely with team members to deliver features on time."

What's the problem? Take a guess before scrolling πŸ‘‡

.
.
.

The roast:
❌ "Responsible for" - passive, says nothing about impact
❌ No numbers. How many applications? How many users? What team size?
❌ "Delivered features on time" - that's the baseline expectation of the job, not an achievement

Rewritten:
> "Built and shipped 4 customer-facing features in React/Node.js used by 50K+ monthly active users; reduced average page load time by 35% through code-splitting and lazy loading."

Same job, same skills - completely different impression. Specifics + numbers = credibility.

Got a resume bullet you're not sure about? Drop it below and I'll roast it (kindly) πŸ”₯
❀1
πŸ” GUESS THE OUTPUT #2 - full breakdown

python
def add_item(item, items=[]):
items.append(item)
return items

print(add_item(1))
print(add_item(2))
print(add_item(3))


Answer:

[1]
[1, 2]
[1, 2, 3]


Surprised? Mutable default arguments in Python are created once, when the function is defined - not each time it's called. So that same list keeps getting reused and mutated across calls.

The fix:
python
def add_item(item, items=None):
if items is None:
items = []
items.append(item)
return items


This exact bug has caused real production incidents. It's also a favorite "gotcha" question at Python-heavy companies.

Did you know about this one, or did it just break your brain a little? πŸ˜„
❀1
πŸ”₯ Binary Search Coding Problems (Must for Interviews) πŸ”πŸ’»

These are high-frequency interview problems based on Binary Search. Focus on logic + pattern recognition.

🧠 1️⃣ Basic Binary Search (Find Element Index)

Problem:
Given a sorted array, find the index of a target element.

Approach:

β€’ Compare with middle
β€’ Go left or right
β€’ Repeat until found

πŸ‘‰ This is the foundation of all binary search problems.

🧠 2️⃣ First Occurrence of Element

Problem:
Find the first position of a target in a sorted array with duplicates.

Example:
Array:, Target = 2 β†’ Output: index 1[1][2][3]

Insight:
πŸ‘‰ Don’t stop at first match
πŸ‘‰ Continue searching on the left side

🧠 3️⃣ Last Occurrence of Element

Problem:
Find the last position of a target.

Example:
Array: β†’ Output: index 3[1][2][3]

Insight:
πŸ‘‰ Move towards the right side after finding match

🧠 4️⃣ Count Occurrences

Problem:
Count how many times a number appears.

Approach:
πŸ‘‰ count = last_index - first_index + 1

🧠 5️⃣ Search in Rotated Sorted Array

Problem:
Array is rotated:
Find target efficiently.[4][5][6][7][0][1][2]

Insight:
πŸ‘‰ One half is always sorted
πŸ‘‰ Decide which side to search

🧠 6️⃣ Find Minimum in Rotated Sorted Array

Problem:
Find smallest element in rotated array.

Example:
β†’ Output: 1[4][5][6][1][2][3]

Insight:
πŸ‘‰ Compare middle with rightmost element

🧠 7️⃣ Square Root using Binary Search

Problem:
Find integer square root of a number.

Example:
√25 β†’ 5

Insight:
πŸ‘‰ Use binary search on range 1 to n

🧠 8️⃣ Peak Element Problem

Problem:
Find an element greater than its neighbors.

Insight:
πŸ‘‰ If mid < next β†’ go right
πŸ‘‰ Else β†’ go left

⚑️ Common Pattern

Binary search is not just for searching. It is used when:
β€’ Data is sorted
β€’ You need optimal solution (log n)
β€’ You can eliminate half of search space

⚠️ Common Mistakes

❌ Wrong mid calculation
❌ Infinite loops
❌ Not updating bounds correctly
❌ Ignoring edge cases
❀1
πŸ’° SALARY NEGOTIATION #1 - The Script You Need

Most engineers leave $10K-$30K on the table because they accept the first offer out of fear the company will rescind it.

They almost never do. Here's a script that works:

When you get the offer:
"Thank you so much, I'm really excited about this. Could I have a couple of days to review everything?"

(Always ask for time. Never negotiate on the spot.)

When you come back to negotiate:
"I'm really excited about this role and the team. Based on my research and the scope of responsibilities we discussed, I was expecting something closer to $X. Is there flexibility on the base salary or the signing bonus?"

Key principles:
βœ… Always express enthusiasm first - negotiation isn't confrontation
βœ… Anchor with a specific number, not a vague "more"
βœ… Ask about total comp flexibility (base, bonus, equity, sign-on) - not just base salary
βœ… Never lie about competing offers, but you CAN say "I'm evaluating a few opportunities"

The worst that happens? They say no, and you're exactly where you started. The best case? Thousands of extra dollars a year, for one polite conversation.

Have you ever negotiated an offer? How did it go? πŸ‘‡
πŸ“Š SQL SATURDAY #2 - JOINs Without the Confusion

Two tables this week:


customers orders
+----+---------+ +----+-------------+--------+
| id | name | | id | customer_id | amount |
+----+---------+ +----+-------------+--------+
| 1 | Alice | | 1 | 1 | 250 |
| 2 | Bob | | 2 | 1 | 100 |
| 3 | Charlie | | 3 | 2 | 75 |
+----+---------+ +----+-------------+--------+


Notice Charlie has no orders.

INNER JOIN - only rows that match in both tables:
sql
SELECT c.name, o.amount
FROM customers c
INNER JOIN orders o ON c.id = o.customer_id;

Charlie won't appear - he has no matching order.

LEFT JOIN - all rows from the left table, matched or not:
sql
SELECT c.name, o.amount
FROM customers c
LEFT JOIN orders o ON c.id = o.customer_id;

Charlie appears with amount = NULL.

⚠️ Interview trap: "Find customers with zero orders."

sql
SELECT c.name
FROM customers c
LEFT JOIN orders o ON c.id = o.customer_id
WHERE o.id IS NULL;


People often try WHERE o.amount = 0 here - wrong, that finds orders worth $0, not customers with no orders at all. Filtering on IS NULL after a LEFT JOIN is the pattern to remember.

Which JOIN type trips you up the most? RIGHT and FULL OUTER are coming in a few weeks πŸ‘€
🧠 EDUCATIONAL CS #2 - Why Hash Tables Are Basically Magic

You use hash tables constantly (Python dicts, JS objects, Java HashMaps) - but do you know why they're O(1)?

Here's the core idea:

1️⃣ You have a hash function that takes a key and turns it into a number (an index).
2️⃣ That index points directly to a slot ("bucket") in an array.
3️⃣ To look up a value, you hash the key again, jump straight to that slot - no searching required.


key "apple" β†’ hash("apple") β†’ index 7 β†’ array[7] = value


That's why lookup, insert, and delete are all O(1) on average.

Why "on average" and not always? Because two different keys can hash to the same index - a collision. When that happens, most implementations chain multiple entries in the same bucket (a small linked list) or probe for the next open slot.

If your hash function is bad and everything collides into one bucket, your "O(1)" hash table quietly degrades into an O(n) linked list. This is exactly why interviewers sometimes ask: "what happens if all your keys hash to the same value?"

Now you know the answer. πŸ˜‰

What's a bug you've hit because of hash collisions or bad hashing? πŸ‘‡
πŸ’¬ DISCUSSION - What's Your Interview Horror Story?

We've all got one. The question that made your brain completely blank. The moment you realized you'd been debugging the wrong function for 10 minutes. The interviewer who just... stared at you in silence.

Drop your worst interview moment below. No judgment - half the people reading this have a story just as bad (including me).

Bonus points if it has a happy ending. πŸ˜„
To effectively learn SQL for a Data Analyst role, follow these steps:

1. Start with a basic course:
Begin by taking a basic course on YouTube to familiarize yourself with SQL syntax and terminologies. I recommend the "Learn Complete SQL" playlist from the "techTFQ" YouTube channel.

2. Practice syntax and commands:
As you learn new terminologies from the course, practice their syntax on the "w3schools" website. This site provides clear examples of SQL syntax, commands, and functions.

3. Solve practice questions:
After completing the initial steps, start solving easy-level SQL practice questions on platforms like "Hackerrank," "Leetcode," "Datalemur," and "Stratascratch." If you get stuck, use the discussion forums on these platforms or ask ChatGPT for help. You can paste the problem into ChatGPT and use a prompt like:
- "Explain the step-by-step solution to the above problem as I am new to SQL, also explain the solution as per the order of execution of SQL."

4. Gradually increase difficulty:
Gradually move on to more difficult practice questions. If you encounter new SQL concepts, watch YouTube videos on those topics or ask ChatGPT for explanations.

5. Consistent practice:
The most crucial aspect of learning SQL is consistent practice. Regular practice will help you build and solidify your skills.

By following these steps and maintaining regular practice, you'll be well on your way to mastering SQL for a Data Analyst role.
πŸ—οΈ SYSTEM DESIGN MONDAY #2 - Caching 101

Last week: client β†’ server β†’ database. Now let's fix the bottleneck.

Say your database gets hit with the same query a thousand times a second - like fetching a popular product page. Hitting disk every time is wasteful.

Enter the cache: a fast, in-memory layer that sits between your server and database.


[Client] β†’ [Server] β†’ [Cache] β†’ [Database]
↑
(checked first)


Flow:
1️⃣ Server checks cache first
2️⃣ Cache hit β†’ return immediately (fast!)
3️⃣ Cache miss β†’ query database, store result in cache, return it

Popular tools: Redis, Memcached.

Two concepts you MUST be able to explain in an interview:

πŸ”Ή Cache eviction (LRU) - cache has limited memory, so when it's full, Least Recently Used items get kicked out to make room for new ones.

πŸ”Ή Cache invalidation - the hardest part. If the underlying data changes, how does the cache know to update? (Famous quote: "There are only two hard things in computer science: cache invalidation and naming things.")

Common strategies: TTL (time-to-live expiry), write-through (update cache and DB together), or explicit invalidation on writes.

Next System Design Monday: what happens when ONE server can't handle the traffic anymore - load balancing.

What would you cache first in a system like Instagram? πŸ‘‡
πŸ› SPOT THE BUG #2
Language: Java

java
public class Counter {
private int count;

public void increment() {
count++;
}

public int getCount() {
return count;
}
}

// Used across 10 threads simultaneously calling increment()


What breaks under concurrent access? πŸ‘‡

.
.
.

The bug: count++ is NOT atomic. It's actually three operations: read, increment, write. Two threads can read the same value, both increment it, and both write back the same result - losing an update. With 10 threads hammering this, your final count will almost always be less than expected.

Fixed version:
java
public class Counter {
private AtomicInteger count = new AtomicInteger(0);

public void increment() {
count.incrementAndGet();
}

public int getCount() {
return count.get();
}
}


Alternative fix: mark increment() as synchronized, though that's slower under high contention than AtomicInteger.

This is one of the most common concurrency bugs in real production systems, not just interviews. Ever debugged something like this in the wild? πŸ‘‡