Interview Prep12 min read

Software Engineer Interview Questions and Answers

Comprehensive guide to common software engineer interview questions, covering technical and behavioral aspects. Includes sample answers, coding problems, and strategies to ace your software engineering interviews.

24 May 2026By CareerHub Team

Software engineer interviews in India have become increasingly standardized — DSA rounds, system design for senior roles, and behavioral questions. But the bar has risen significantly from 2020, especially at top product companies.

Our take: The biggest mistake candidates make is focusing only on LeetCode. Companies are increasingly testing system design, debugging skills, and real-world engineering judgment. Balance your DSA practice with building actual projects.

Technical Interview Questions

1. Data Structures and Algorithms

Question: Reverse a linked list

Expected approach:

  • Use three pointers: previous, current, next
  • Iterate through the list, reversing the links
  • Time complexity: O(n), Space complexity: O(1)

Sample code (Python):

def reverse_linked_list(head):
    prev = None
    current = head
    while current:
        next_node = current.next
        current.next = prev
        prev = current
        current = next_node
    return prev

Question: Find the first non-repeated character in a string

Expected approach:

  • Use a hash map to count character frequencies
  • Iterate through string again to find first non-repeated character
  • Time complexity: O(n), Space complexity: O(1) (limited character set)

Sample code:

def first_non_repeated_char(s):
    char_count = {}
    for char in s:
        char_count[char] = char_count.get(char, 0) + 1
    for char in s:
        if char_count[char] == 1:
            return char
    return None

2. System Design

Question: Design Twitter

Key components:

  • User management
  • Tweet posting
  • Timeline generation (home timeline, user timeline)
  • Follow/unfollow system
  • Trending topics

Considerations:

  • Scale: millions of users, tweets per second
  • Latency: timelines should load quickly
  • Storage: efficient storage of tweets and user relationships
  • Consistency vs availability

High-level design:

  • Use a distributed system with microservices
  • User service, tweet service, timeline service
  • Database sharding for scalability
  • Caching layer (Redis) for frequent queries
  • CDN for media content

Question: Design a URL shortener like TinyURL

Key components:

  • URL shortening algorithm
  • Redirect service
  • Analytics (click tracking)
  • Custom short URLs

Considerations:

  • Handle large volume of URLs
  • Low latency redirects
  • Prevent abuse (spam, malicious URLs)
  • Scalability

Design elements:

  • Hash function to generate short codes
  • Database to store original and short URLs
  • Caching layer for frequently accessed URLs
  • Rate limiting to prevent abuse

Coding Challenges

1. Two Sum Problem

Problem: Given an array of integers and a target sum, find two numbers that add up to the target.

Expected solution:

  • Use hash map to store numbers and their indices
  • Time complexity: O(n), Space complexity: O(n)

Sample code:

def two_sum(nums, target):
    num_map = {}
    for i, num in enumerate(nums):
        complement = target - num
        if complement in num_map:
            return [num_map[complement], i]
        num_map[num] = i
    return []

2. Merge K Sorted Lists

Problem: Merge k sorted linked lists into one sorted list.

Expected approaches:

  • Use min-heap: O(n log k) time, O(k) space
  • Divide and conquer: O(n log k) time, O(1) space
  • Brute force: O(nk) time

Sample code (min-heap approach):

import heapq

def merge_k_lists(lists):
    heap = []
    for i, lst in enumerate(lists):
        if lst:
            heapq.heappush(heap, (lst.val, i, lst))
    
    dummy = ListNode(0)
    current = dummy
    
    while heap:
        val, i, node = heapq.heappop(heap)
        current.next = ListNode(val)
        current = current.next
        if node.next:
            heapq.heappush(heap, (node.next.val, i, node.next))
    
    return dummy.next

Behavioral Questions

1. Tell me about a time you faced a conflict with a team member

Use STAR method:

  • Situation: Describe the context
  • Task: What needed to be done?
  • Action: What steps did you take?
  • Result: What was the outcome?

Sample answer: "Situation: In my previous project, my teammate and I disagreed on the technology stack for a new feature.

Task: We needed to decide between using React or Vue for the frontend.

Action: I scheduled a meeting to understand their perspective, then presented data on performance and learning curve. We decided to run small experiments with both frameworks and evaluate after two weeks.

Result: The experiments helped us make a data-driven decision. We chose React, and the feature was delivered successfully. We also established a better process for technical disagreements."

2. Tell me about a time you failed

What they're looking for: Self-awareness, learning ability, resilience.

Sample answer: "Early in my career, I took on a project without fully understanding the requirements. I built the entire feature based on my assumptions, only to realize later that I had misunderstood key aspects. It resulted in wasted time and effort.

I learned the importance of clarifying requirements before starting work. Now, I always create detailed specification documents and get stakeholder sign-off before writing any code."

3. Why do you want to work at this company?

What they're looking for: Preparation, genuine interest, cultural fit.

Sample answer: "I've been following your company's growth, especially your recent expansion into AI-powered products. I'm impressed by your engineering culture and commitment to innovation. The [specific product] you launched last year solves a real problem in a elegant way. I believe my skills in backend development would allow me to contribute meaningfully while growing as an engineer."

System Design Questions

1. Design a web crawler

Key considerations:

  • Politeness: Don't overwhelm websites
  • Deduplication: Avoid crawling same page multiple times
  • Scalability: Handle millions of URLs
  • Robustness: Handle errors, timeouts

Components:

  • Seed URLs
  • URL frontier (queue)
  • Fetcher (downloads pages)
  • Extractor (extracts links from pages)
  • Duplicate detection
  • Storage

Algorithms:

  • Breadth-first search
  • Bloom filters for deduplication
  • Politeness policies (delay between requests)

2. Design a key-value store like Redis

Key features:

  • In-memory storage
  • Persistence options (RDB, AOF)
  • Replication
  • High availability
  • Data structures (strings, lists, sets, etc.)

Considerations:

  • Memory efficiency
  • Low latency
  • Data eviction policies
  • Clustering for scalability

Language-Specific Questions

Python

Question: What's the difference between lists and tuples? Answer: Lists are mutable, tuples are immutable. Lists use dynamic arrays, tuples use static arrays. Tuples are faster for read operations.

Question: Explain Python's GIL Answer: Global Interpreter Lock prevents multiple threads from executing Python bytecodes at once. It ensures thread safety but limits concurrency for CPU-bound tasks.

JavaScript

Question: What's the difference between null and undefined? Answer: Null is an assignment value, undefined means variable not declared or not assigned. Null is an object, undefined is a type.

Question: Explain event delegation Answer: Technique where you bind event handlers to a parent element instead of each child element. Improves performance and handles dynamically added elements.

Java

Question: What's the difference between abstract class and interface? Answer: Abstract classes can have method implementations, interfaces cannot. A class can implement multiple interfaces but extend only one abstract class. Abstract classes can have fields, interfaces cannot (until Java 9).

Question: Explain the Java memory model Answer: Heap memory (objects), stack memory (local variables), method area (class metadata), program counter, native method stack.

Database Questions

1. SQL Queries

Question: Find the second highest salary from Employees table. Answer:

SELECT MAX(salary) FROM Employees WHERE salary NOT IN (SELECT MAX(salary) FROM Employees);

Or using LIMIT:

SELECT salary FROM Employees ORDER BY salary DESC LIMIT 1 OFFSET 1;

2. Database Design

Question: Design a database schema for a parking lot system. Key entities:

  • Parking lot (has many spots)
  • Parking spot (reserved/available)
  • Ticket (entry/exit times, payment)
  • Payment
  • User (optional, for monthly passes)

Relationships:

  • One lot has many spots
  • One ticket has one spot
  • One payment per ticket

Considerations:

  • Concurrency control for spot allocation
  • Indexing for fast queries
  • Partitioning for large lots

Operating Systems Questions

1. Process vs Thread

Process: Independent program execution with its own memory space. Heavier, more isolation.

Thread: Lightweight process within a process. Shares memory space, faster context switching.

2. Deadlock Prevention

Conditions for deadlock:

  1. Mutual exclusion
  2. Hold and wait
  3. No preemption
  4. Circular wait

Prevention strategies:

  • Eliminate one condition (e.g., no preemption)
  • Resource allocation graphs
  • Banker's algorithm

3. Memory Management

Virtual memory: Illusion of more memory than physically available.

Paging: Memory management scheme that eliminates need for contiguous memory allocation.

Segmentation: Memory management scheme that supports user view of memory.

Networking Questions

1. OSI Model Layers

Seven layers:

  1. Physical
  2. Data Link
  3. Network
  4. Transport
  5. Session
  6. Presentation
  7. Application

2. HTTP vs HTTPS

HTTP: Hypertext Transfer Protocol, unsecured.

HTTPS: HTTP Secure, uses SSL/TLS encryption.

3. TCP vs UDP

TCP: Connection-oriented, reliable, slower. Used for web browsing, email.

UDP: Connectionless, unreliable, faster. Used for video streaming, gaming.

Conclusion

Software engineering interviews test a broad range of skills. The key to success:

  1. Master fundamentals (data structures, algorithms, system design)
  2. Practice coding regularly on platforms like LeetCode
  3. Understand system design principles
  4. Prepare behavioral answers using STAR method
  5. Know your tools (languages, databases, networking)
  6. Stay updated with industry trends

Remember: interviews are a two-way street. You're also evaluating the company. Ask thoughtful questions and ensure the role aligns with your career goals.


Need help with specific software engineering interview questions? Check out our guides on system design interviews, coding challenge strategies, and behavioral interview techniques.

This article is managed from MDX content.