CODING INTERVIEW
SYSTEM DESIGN

Software Engineer Interview Questions & Answers 2025

Master coding interviews with 20+ technical questions covering algorithms, system design, data structures, and behavioral scenarios. Practice with our AI coding assistant for top tech companies like Google, Meta, Amazon, and Microsoft.

Software Engineer Interview Questions

1. How do you implement a function to reverse a linked list?
Arrow for FAQ top
Expert Answer: Use iterative approach with three pointers: previous, current, next. Initialize previous as null, current as head. While current exists: store next node, reverse link by pointing current.next to previous, move previous to current, current to next. Return previous as new head. Time: O(n), Space: O(1).

Example: "I implemented this for our data processing pipeline. The iterative solution is preferred because it uses constant space. Here's the approach: maintain three pointers to track previous, current, and next nodes. In each iteration, reverse the current node's pointer and advance all three pointers. This ensures we don't lose track of the remaining list while reversing connections."
2. How do you design a chat application like WhatsApp?
Arrow for FAQ top
Expert Answer: Architecture includes client apps, load balancers, chat servers, message queue, databases. Use WebSocket for real-time messaging, message queues (Kafka/RabbitMQ) for reliable delivery, NoSQL for message storage, Redis for online user status. Implement message encryption, push notifications, media handling, and group chat functionality.

Example: "I designed a messaging system for 10M+ users. Used WebSocket connections for real-time communication, Kafka for message queuing to handle high throughput, MongoDB for message persistence with sharding by user_id. Implemented presence service with Redis for online status, CDN for media files, and push notification service for offline users. Added end-to-end encryption for security."
3. What's the difference between SQL and NoSQL databases?
Arrow for FAQ top
Expert Answer: SQL databases (MySQL, PostgreSQL) use structured schemas, ACID properties, and relational model. Best for complex queries, transactions, and consistency requirements. NoSQL databases (MongoDB, Cassandra) offer flexible schemas, horizontal scaling, and eventual consistency. Choose SQL for financial systems, e-commerce; NoSQL for big data, real-time analytics.

Example: "In our e-commerce platform, I used PostgreSQL for order management and financial transactions because ACID compliance was critical. For product catalogs and user activity tracking, I chose MongoDB because it handled varying product attributes better and scaled horizontally as our catalog grew from 10K to 1M+ products."
4. What are microservices and their advantages?
Arrow for FAQ top
Expert Answer: Microservices architecture breaks applications into small, independent services communicating via APIs. Advantages: independent deployment, technology diversity, fault isolation, team autonomy, easier scaling. Challenges: network complexity, data consistency, monitoring overhead, increased latency.

Example: "I led the migration of our monolithic application to microservices. Split into User Service (Node.js), Product Service (Python), Order Service (Java), and Payment Service (Go). This allowed independent scaling - we could scale Product Service during sales without affecting other services. However, we needed to implement distributed tracing, service mesh, and proper monitoring to manage the complexity."
5. How do you handle authentication and authorization?
Arrow for FAQ top
Expert Answer: Authentication verifies user identity (who you are), authorization controls access (what you can do). Implement JWT tokens for stateless authentication, OAuth 2.0 for third-party integration, role-based access control (RBAC) for permissions. Use HTTPS, secure token storage, token expiration, and refresh token rotation.

Example: "I implemented JWT-based authentication with 15-minute access tokens and 7-day refresh tokens. Used bcrypt for password hashing, implemented role-based permissions (admin, editor, viewer), and integrated OAuth for Google/Facebook login. Added rate limiting to prevent brute force attacks and implemented automatic token refresh to improve user experience while maintaining security."
6. Explain Big O notation and analyze algorithm complexity
Arrow for FAQ top
Expert Answer: Big O describes algorithm's worst-case time/space complexity as input grows. O(1) constant, O(log n) logarithmic, O(n) linear, O(n log n) linearithmic, O(n²) quadratic, O(2ⁿ) exponential. Examples: array access O(1), binary search O(log n), linear search O(n), merge sort O(n log n), bubble sort O(n²).

Example: "When optimizing our search feature, I analyzed different approaches: linear search O(n) was too slow for 1M+ records, so I implemented binary search O(log n) on sorted data and hash table lookups O(1) for exact matches. This reduced search time from 2 seconds to 50ms. I always consider both time and space complexity when choosing algorithms."
7. What is REST API design and best practices?
Arrow for FAQ top
Expert Answer: REST uses HTTP methods semantically: GET (retrieve), POST (create), PUT (update), DELETE (remove). URLs represent resources as nouns, not actions. Use proper status codes (200, 201, 400, 404, 500), implement versioning (/v1/users), consistent naming conventions, pagination for large datasets, and comprehensive error messages.

Example: "I designed RESTful APIs for our mobile app backend. Used resource-based URLs like /api/v1/users/{id}/orders, implemented proper HTTP status codes, added pagination with limit/offset parameters, and comprehensive error responses with error codes and messages. Added API documentation with OpenAPI/Swagger and implemented rate limiting for security."
8. How do you optimize database performance?
Arrow for FAQ top
Expert Answer: Use proper indexing for frequently queried columns, avoid N+1 queries with eager loading, implement database connection pooling, optimize query execution plans, consider read replicas for scaling. Monitor slow queries, use appropriate data types, normalize for consistency or denormalize for performance. Implement caching strategies.

Example: "I optimized our slow product search queries by adding composite indexes on (category, price, created_at), implemented connection pooling to handle 1000+ concurrent users, and added Redis caching for frequently accessed data. Used database query profiling to identify and optimize slow queries, reducing average response time from 800ms to 50ms."
9. Implement binary search algorithm
Arrow for FAQ top
Expert Answer: Binary search works on sorted arrays by repeatedly dividing search space in half. Compare target with middle element: if equal, return index; if target is smaller, search left half; if larger, search right half. Continue until found or search space empty. Time complexity: O(log n), Space: O(1) iterative.

Example: "I implemented binary search for our auto-complete feature on a sorted list of 100K+ product names. The iterative approach with careful handling of integer overflow (mid = left + (right - left) / 2) ensures O(log n) performance. This reduced search time from linear O(n) scanning to logarithmic lookup, enabling real-time suggestions as users type."
10. How do you handle errors and exceptions in code?
Arrow for FAQ top
Expert Answer: Use try-catch blocks for expected exceptions, implement global error handlers for unhandled cases, log errors with context information, return meaningful error messages to users, and use appropriate HTTP status codes in APIs. Implement circuit breakers for external service calls, retry mechanisms with exponential backoff, and graceful degradation.

Example: "I implemented comprehensive error handling in our API using custom exception classes, centralized error logging with structured logs including request IDs for tracing, and circuit breakers for third-party service calls. Added retry logic with exponential backoff for transient failures and graceful degradation - when payment service was down, users could still browse products with checkout disabled."