Python Interview Questions 2026

Published July 22, 2026 · Updated July 22, 2026

59 Python interview questions from Amazon, Google, Swiggy, Meta. All difficulty levels, all roles. Upvoted by engineers who were asked them.

59 questions
Companies: Amazon, Google, Swiggy, Meta
4100 upvotes

Python Questions by Company

Amazon (5)

Amazon Medium Technical round JavaPythonJavaScript

Given an array of integers and a target sum, return all unique triplets that sum to the target. Discuss time and space complexity. Then extend the problem to k-sum and analyze how recursion depth changes performance for large k.

↑ 54 upvotes · 47 engineers asked this · SDE2
Amazon Medium Technical round JavaPython

Given an array of integers, find the length of the longest subarray with a sum equal to zero. Explain the prefix sum + HashMap approach and why the naive O(n2) solution is unacceptable for large inputs.

↑ 51 upvotes · 32 engineers asked this · SDE1
Amazon Medium Technical round JavaPython

Serialize and deserialize a binary tree. Implement both functions and explain why BFS serialization makes deserialization simpler than DFS. What is the time and space complexity?

↑ 44 upvotes · 27 engineers asked this · SDE1
Amazon Hard Scenario round 4–7 YearsPythonKafka

You have a Spark job that ingests 500GB of clickstream data daily. It is failing with OOM errors on the executor. How do you debug and fix it?

↑ 108 upvotes · 86 engineers asked this · Data Engineer
Amazon Medium Technical round 2-5 yearsPython

Explain how Python's dictionary achieves average O(1) lookup. What happens internally when two keys hash to the same bucket?

↑ 22 upvotes · 14 engineers asked this · SDE2

Google (5)

Google Medium Technical round JavaC++Python

Given a binary tree, return the boundary of the tree in anti-clockwise direction starting from the root. The boundary consists of the left boundary, leaves, and the right boundary in reverse.

↑ 96 upvotes · 31 engineers asked this · SDE2
Google Hard Technical round JavaPythonGo

Implement a topological sort for a directed acyclic graph. Then extend it to detect cycles and explain how this maps to dependency resolution in build systems like Bazel.

↑ 61 upvotes · 38 engineers asked this · SDE2
Google Medium Technical round JavaPythonC++

Given a list of intervals, merge all overlapping intervals and return the result. Explain the sort-then-scan approach and the edge cases (touching intervals, single interval, all disjoint).

↑ 67 upvotes · 43 engineers asked this · SDE1
Google Hard Scenario round 5–8 YearsLLMRAGPython

Our RAG pipeline responses are accurate in staging but hallucinate in production on long user queries. Walk me through how you debug and fix this.

↑ 112 upvotes · 89 engineers asked this · AI Engineer
Google Medium Technical round 2-5 yearsPython

You have a 50GB CSV file and only 8GB of RAM. Walk through how you would compute the average of one column using pandas without crashing the process.

↑ 33 upvotes · 19 engineers asked this · Data Scientist

Swiggy (3)

Swiggy Medium Technical round JavaPython

Given a list of delivery time windows for N restaurants, find the maximum number of restaurants whose windows overlap at any point in time. Explain the sweep-line approach, time complexity, and how this maps to capacity planning for Swiggy's logistics team.

↑ 78 upvotes · 29 engineers asked this · SDE1
Swiggy Medium Technical round RedisJavaPython

Implement a rate limiter for Swiggy's API gateway using the token bucket algorithm. Handle 1000 requests/second per user. Code the solution and explain how you'd deploy it across multiple API servers with Redis.

↑ 49 upvotes · 30 engineers asked this · SDE1
Swiggy Medium Technical round JavaPython

Given delivery time estimates for N restaurants, find the restaurant with the minimum average delivery time across all its orders. Handle ties and explain your data structure choices.

↑ 41 upvotes · 24 engineers asked this · SDE1

Meta (5)

Meta Hard Technical round JavaPythonDistributed Systems

Given Meta's social graph, find all friend-of-friend recommendations for a user that are not already friends. Discuss BFS at scale, how to prune the search space, and how to rank recommendations by mutual friend count efficiently.

↑ 54 upvotes · 54 engineers asked this · SDE2
Meta Medium Technical round PythonJava

Given a social graph, find all users within K hops of a given user. Implement BFS with a visited set. Then discuss how you would scale this to Meta's 3 billion user graph using partitioning.

↑ 58 upvotes · 37 engineers asked this · SDE1
Meta Medium Technical round PythonJavaJavaScript

Given an array of N integers, find the maximum product subarray. Explain why you need to track both the maximum and minimum product ending at each position, and handle zeros and negative numbers.

↑ 52 upvotes · 33 engineers asked this · SDE1
Meta Hard Scenario round 5–8 YearsLLMPythonML/AI

Your fine-tuned LLM performs well on your eval set but users report degraded responses 2 weeks after deployment. What is happening and what do you do?

↑ 104 upvotes · 82 engineers asked this · AI Engineer
Meta Medium Technical round 3–6 YearsPython

What is the difference between RANK(), DENSE_RANK(), and ROW_NUMBER()? Give a real use case for each.

↑ 89 upvotes · 71 engineers asked this · Data Engineer

Zomato (2)

Zomato Medium Technical round JavaPython

Given a list of restaurant ratings and a minimum threshold, return the top-k restaurants sorted by rating using a min-heap. Explain why a heap beats a full sort for large k, and the time complexity of both approaches.

↑ 61 upvotes · 22 engineers asked this · SDE1
Zomato Medium Technical round PythonJava

How does Zomato calculate a restaurant's "delivery fee"? The fee depends on distance, demand, time of day, and partner availability. Implement a pricing function given these inputs and discuss fairness trade-offs.

↑ 43 upvotes · 27 engineers asked this · SDE1

Microsoft (5)

Microsoft Medium Technical round JavaC#Python

Given a binary tree, print nodes level by level (BFS traversal). Then modify it to print alternate levels in reverse order (zigzag traversal). Analyse time and space complexity.

↑ 61 upvotes · 40 engineers asked this · SDE1
Microsoft Hard Technical round JavaPythonC#

Given a 2D grid of 0s and 1s, count the number of islands. Then extend: find the largest island, and then explain how you would solve this for a streaming grid that changes in real time using a Union-Find structure.

↑ 54 upvotes · 34 engineers asked this · SDE2
Microsoft Easy Screening round JavaC#Python

Find all pairs in an array that sum to a given target value. Explain the HashSet approach for O(n) time, handle duplicate pairs correctly, and discuss edge cases (negative numbers, empty array).

↑ 55 upvotes · 37 engineers asked this · SDE1
Microsoft Hard Scenario round 4–7 YearsLLMPython

You are building an AI agent that books travel. It has access to 6 tools. How do you prevent it from calling tools in the wrong order or entering infinite loops?

↑ 98 upvotes · 76 engineers asked this · AI Engineer
Microsoft Medium Technical round 2-5 yearsPython

Write a Python decorator @timed that prints how long a function took to execute, and explain how functools.wraps prevents it from breaking introspection.

↑ 20 upvotes · 11 engineers asked this · Senior SDE

Flipkart (1)

Flipkart Medium Technical round JavaPython

Given a directed graph representing category hierarchies in an e-commerce catalog, find the shortest path between two categories. Explain BFS vs Dijkstra for unweighted vs weighted graphs.

↑ 33 upvotes · 18 engineers asked this · SDE1

Apple (1)

Apple Medium Technical round SwiftJavaPython

Given a BST, find the closest value to a given target. Explain the O(log n) iterative approach using BST properties, and how the answer changes if the tree is unbalanced.

↑ 41 upvotes · 24 engineers asked this · SDE1

Netflix (2)

Netflix Medium Technical round PythonJava

Given a list of movie ratings (1-5 stars) for N users, compute the Pearson correlation between two users to measure taste similarity. Explain how this feeds into collaborative filtering.

↑ 44 upvotes · 27 engineers asked this · SDE1
Netflix Hard System Design round 5–8 YearsPythonKafkaSnowflake

Design a data pipeline to ingest CDC (Change Data Capture) events from a MySQL database into a Snowflake data warehouse in near real-time.

↑ 131 upvotes · 103 engineers asked this · Data Engineer

Uber (5)

Uber Hard Technical round JavaPythonGo

Given a city map as a weighted graph, find the shortest travel time from a driver's current location to all potential passenger pickup points simultaneously. How does Dijkstra's multi-source variant solve this?

↑ 49 upvotes · 30 engineers asked this · SDE1
Uber Medium Technical round JavaPython

Given a list of GPS coordinates representing a driver's path, compute the total distance travelled. Then find the longest contiguous segment where the driver was stationary (speed < 5 km/h). Discuss floating-point precision issues.

↑ 42 upvotes · 26 engineers asked this · SDE1
Uber Hard Scenario round 4–6 YearsPythonKafka

Your pipeline SLA requires data to be available in the warehouse by 6 AM. Yesterday it missed at 7:30 AM. Walk me through your incident response.

↑ 96 upvotes · 74 engineers asked this · Data Engineer
Uber Hard Scenario round 5–8 YearsPython

Your PySpark job has data skew on a join key (user_id) where 1% of users account for 60% of the data. How do you handle it?

↑ 117 upvotes · 91 engineers asked this · Data Engineer
Uber Medium Technical round 3-6 yearsPythonSystem Design

You need to find all available drivers within a 3km radius of a rider efficiently, with millions of driver location updates per second. What indexing structure would you use and why not a naive distance calculation over all drivers?

↑ 32 upvotes · 15 engineers asked this · Senior SDE

Airbnb (3)

Airbnb Medium Technical round JavaPython

Given a list of bookings with start and end dates, find the minimum number of rooms needed so that no two overlapping bookings share a room. Explain the sweep-line and min-heap approaches.

↑ 63 upvotes · 42 engineers asked this · SDE1
Airbnb Medium Technical round PythonDistributed Systems

How does Airbnb's dynamic pricing work? Given historical booking data, seasonality, local events, and competitor prices, how do you recommend a nightly rate that maximises host revenue? Discuss the ML pipeline.

↑ 51 upvotes · 31 engineers asked this · SDE2
Airbnb Hard Scenario round 4–7 YearsPythonSnowflake

Your team discovers that 20% of user_id values in the orders table do not match any record in the users table. How do you handle this as a data engineer?

↑ 102 upvotes · 81 engineers asked this · Data Engineer

Adobe (1)

Adobe Medium Technical round C++PythonJava

Implement a basic version of Adobe Lightroom's non-destructive editing model. All edits (brightness, contrast, crop) are stored as a list of operations, not applied to the original image. Explain the data structure and how you apply/undo operations.

↑ 49 upvotes · 30 engineers asked this · SDE1

Atlassian (2)

Atlassian Medium Technical round JavaPython

Given a list of Jira sprint start/end dates, find all sprints that overlap with a given date range. Implement an efficient solution using interval trees or sorted arrays with binary search.

↑ 42 upvotes · 25 engineers asked this · SDE1
Atlassian Medium Technical round 3–6 YearsPython

What are Airflow Sensors and when would you use a FileSensor vs an HttpSensor vs an ExternalTaskSensor?

↑ 78 upvotes · 61 engineers asked this · Data Engineer

PayU (2)

PayU Medium Technical round 2–5 YearsInterview ExperienceJavaScriptJavaPython

Given an array of transaction amounts, find all pairs whose sum equals a given target. Return the count of unique pairs. For example: [100, 200, 300, 400], target = 500 → pairs: (100,400), (200,300) → count: 2. What is the time and space complexity of your approach?

↑ 61 upvotes · 42 engineers asked this · Full Stack Developer
PayU Medium Technical round 2–5 YearsInterview ExperienceJavaScriptJavaPython

Given a 2D matrix representing a payment heatmap (rows = hours, columns = days), find the submatrix with the maximum sum. The submatrix represents the peak payment activity window. Describe your approach — can you do better than O(n³)?

↑ 44 upvotes · 29 engineers asked this · Full Stack Developer

General (5)

General Medium Scenario round 5–8 YearsSnowflakeAWS S3Python

A file lands in AWS S3 and must be ingested into Snowflake automatically in near real-time. How would you design the solution? Explain the role of Snowpipe, event notifications, and the ingestion workflow.

↑ 67 upvotes · 48 engineers asked this · Data Engineer
General Hard Scenario round 5–8 YearsSnowflakeSQLPython

Snowpipe is ingesting duplicate records from cloud storage. How would you detect, prevent, and remediate duplicate data in Snowflake?

↑ 83 upvotes · 59 engineers asked this · Data Engineer
General Hard Scenario round 5–8 YearsSnowflakeSQLPython

A query that previously completed in 2 minutes now takes 20 minutes. Describe your systematic approach to troubleshooting and optimizing performance in Snowflake.

↑ 91 upvotes · 65 engineers asked this · Data Engineer
General Hard Scenario round 5–8 YearsSnowflakePySparkAirflow

Design an end-to-end data pipeline using Python, PySpark, Snowflake, Airflow, and AWS S3. Explain data flow, orchestration, monitoring, and failure handling.

↑ 87 upvotes · 62 engineers asked this · Data Engineer
General Medium Technical round 1-4 yearsPython

What is the difference between .loc[] and .iloc[] in pandas? Give an example where using the wrong one silently returns the wrong row.

↑ 22 upvotes · 13 engineers asked this · Data Scientist

Anthropic (1)

Anthropic Hard Technical round 4–8 YearsLLMRAGPython

How would you reduce the latency of a RAG pipeline from 4 seconds to under 1 second in production?

↑ 119 upvotes · 94 engineers asked this · AI Engineer

OpenAI (1)

OpenAI Medium Technical round 2–5 YearsLLMPython

Explain the difference between zero-shot, few-shot, and chain-of-thought prompting. When would you choose each in production?

↑ 87 upvotes · 68 engineers asked this · AI Engineer

TikTok (1)

TikTok Hard Scenario round 6–10 YearsLLMML/AIPython

Design an AI content moderation system for a social platform with 10 million daily posts. How do you balance accuracy, cost, and latency?

↑ 126 upvotes · 97 engineers asked this · AI Engineer

JPMorgan (1)

JPMorgan Medium Technical round 3–6 YearsPython

What is the difference between narrow and wide transformations in Spark? Why does it matter for performance?

↑ 84 upvotes · 66 engineers asked this · Data Engineer

Walmart (1)

Walmart Medium Scenario round 4–6 YearsPython

You need to join a 500GB transaction table with a 5MB lookup table (country codes). The join is taking 20 minutes. How do you fix it?

↑ 92 upvotes · 72 engineers asked this · Data Engineer

Cognizant (1)

Cognizant Medium Technical round 3–5 YearsPython

What is the difference between cache() and persist() in Spark? When should you use StorageLevel.MEMORY_AND_DISK?

↑ 76 upvotes · 59 engineers asked this · Data Engineer

Siemens (1)

Siemens Hard Scenario round 5–7 YearsPythonKafka

You have a streaming PySpark job reading from Kafka that processes IoT sensor events. Events can arrive up to 10 minutes late. How do you handle late data correctly?

↑ 101 upvotes · 79 engineers asked this · Data Engineer

Spotify (1)

Spotify Hard Scenario round 4–7 YearsPython

Your Airflow DAG that runs at midnight has been running for 6 hours and is still not complete. SLA breached. What do you do and how do you prevent it next time?

↑ 99 upvotes · 78 engineers asked this · Data Engineer

DoorDash (1)

DoorDash Medium Technical round 3–5 YearsPython

What is the difference between Airflow TaskFlow API (@task decorator) and traditional PythonOperator? When would you prefer each?

↑ 83 upvotes · 65 engineers asked this · Data Engineer

LinkedIn (1)

LinkedIn Hard Technical round 4–7 YearsPython

How does Airflow handle backfilling? Design a DAG that safely backfills 90 days of missing data without overloading the database.

↑ 96 upvotes · 75 engineers asked this · Data Engineer

Grab (2)

Grab Hard Scenario round 5–8 YearsPython

You need to run a DAG that processes 10,000 files daily — one task per file. How do you design this in Airflow without creating 10,000 static tasks?

↑ 122 upvotes · 95 engineers asked this · Data Engineer
Grab Medium Technical round 2-5 yearsJavaPython

Given an array of ride fare amounts collected over a day, find the maximum sum of any contiguous subarray of exactly k rides (a sliding window problem). Walk through the O(n) approach.

↑ 25 upvotes · 17 engineers asked this · Senior SDE

Practice these questions with AI feedback

Get instant grading on your answers, identify your weak areas, and generate a personalised 14-day study plan — all free.

Build my study plan →

Python questions at each company

Amazon Python Google Python Meta Python Microsoft Python Uber Python General Python

Frequently asked questions

Given an array of integers and a target sum, return all unique triplets that sum to the target. Discuss time and space complexity. Then extend the problem to k-sum and analyze how recursion depth changes performance for large k.
Given an array of integers and a target sum, return all unique triplets that sum to the target. Discuss time and space complexity. Then extend the problem to k-sum and analyze how recursion depth changes performance for large k.
Given a binary tree, return the boundary of the tree in anti-clockwise direction starting from the root. The boundary consists of the left boundary, leaves, and the right boundary in reverse.
Given a binary tree, return the boundary of the tree in anti-clockwise direction starting from the root. The boundary consists of the left boundary, leaves, and the right boundary in reverse.
Given a list of delivery time windows for N restaurants, find the maximum number of restaurants whose windows overlap at any point in time.
Given a list of delivery time windows for N restaurants, find the maximum number of restaurants whose windows overlap at any point in time. Explain the sweep-line approach, time complexity, and how this maps to capacity planning for Swiggy's logistics team.
Given Meta's social graph, find all friend-of-friend recommendations for a user that are not already friends.
Given Meta's social graph, find all friend-of-friend recommendations for a user that are not already friends. Discuss BFS at scale, how to prune the search space, and how to rank recommendations by mutual friend count efficiently.
Given a list of restaurant ratings and a minimum threshold, return the top-k restaurants sorted by rating using a min-heap.
Given a list of restaurant ratings and a minimum threshold, return the top-k restaurants sorted by rating using a min-heap. Explain why a heap beats a full sort for large k, and the time complexity of both approaches.