Data Scientist Coding & Algorithms Interview Questions
Practice 335 real Coding & Algorithms interview questions for Data Scientist roles. From companies including Amazon, Google, Two Sigma, Pinterest, Uber.

"I got asked a hardcore MCM DP question and I saw it on PracHub as well. Solved that question in 5 minutes. Without PracHub I doubt I could solve it in 5 hours. Though somehow didn't get hired, perhaps I guess I solved it too fast? /s"

"Believe me i'm a student here jn US. Recently interviewed for MSFT. They asked me exact question from PracHub. I saw it the night before and ignored it cause why waste time on random sites. I legit wanna go back and redo this whole thing if I had chance. Not saying will work for everyone but there is certainly some merit to that website. And i'm gonna use it in future prep from now on like lc tagged"

"10 years of experience but never worked at a top company. PracHub's senior-level questions helped me break into FAANG at 35. Age is just a number."

"I was skeptical about the 'real questions' claim, so I put it to the test. I searched for the exact question I got grilled on at my last Meta onsite... and it was right there. Word for word."

"Got a Google recruiter call on Monday, interview on Friday. Crammed PracHub for 4 days. Passed every round. This platform is a miracle worker."

"I've used LC, Glassdoor, and random Discords. Nothing comes close to the accuracy here. The questions are actually current — that's what got me. Felt like I had a cheat sheet during the interview."

"The solution quality is insane. It covers approach, edge cases, time complexity, follow-ups. Nothing else comes close."

"Legit the only resource you need. TC went from 180k -> 350k. Just memorize the top 50 for your target company and you're golden."

"PracHub Premium for one month cost me the price of two coffees a week. It landed me a $280K+ starting offer."

"Literally just signed a $600k offer. I only had 2 weeks to prep, so I focused entirely on the company-tagged lists here. If you're targeting L5+, don't overthink it."

"Coaches and bootcamp prep courses cost around $200-300 but PracHub Premium is actually less than a Netflix subscription. And it landed me a $178K offer."

"I honestly don't know how you guys gather so many real interview questions. It's almost scary. I walked into my Amazon loop and recognized 3 out of 4 problems from your database."

"Discovered PracHub 10 days before my interview. By day 5, I stopped being nervous. By interview day, I was actually excited to show what I knew."

"I recently cleared Uber interviews (strong hire in the design round) and all the questions were present in prachub."
"The search is what sold me. I typed in a really niche DP problem I got asked last year and it actually came up, full breakdown and everything. These guys are clearly updating it constantly."
Move zeros to the front
Given an integer array nums, move all elements equal to 0 to the beginning of the array while preserving the relative order of all non-zero elements. ...
Sort a nearly sorted array
Given an array of length \(n\) in which every element is at most \(k\) positions away from its location in the fully sorted order, design an algorithm...
Implement Connect Four Winner Detection
Implement a Connect Four-style game engine. The board has 6 rows and 7 columns. Two players alternate turns. On each turn, the current player chooses ...
Move zeros to front
This question evaluates array manipulation and in-place algorithm skills, specifically competency in stable element reordering, index management, and ...
Implement palindrome check and valid parentheses
You have 20–25 minutes per problem. Implement the following two functions and be prepared to explain your approach and time/space complexity. Problem ...
Answer ancestor-walk queries on a rooted tree
Problem (Tree / Parent Array Queries) You are given a rooted tree with n nodes labeled 1..n, represented by a parent array par[1..n]: - par[i] is the ...
Convert a PDF to a CDF
Given a continuous random variable X with probability density function f(x), write code or describe an algorithm to construct its cumulative distribut...
Implement Jackknife and Random Choice
This question evaluates understanding of statistical resampling (jackknife), probabilistic sampling algorithms including with- and without-replacement...
Implement stack variants and upward path sum
Question Answer the following coding questions. They progress from augmented stacks to streaming statistics to tree path reasoning. 1. MinStack — Desi...
Estimate Two Conditional Win Probabilities by Simulation
Estimate Two Conditional Win Probabilities by Simulation You are given a game with three closed doors, labeled 0, 1, and 2. Behind exactly one door is...
Count Interior Islands After Flooding
You are given an m x n binary grid representing land and water. - 1 = land - 0 = water An island is a maximal group of land cells connected 4-directio...
Compute Fibonacci Numbers
Write a function that returns the nth Fibonacci number. Definitions and requirements: - Use zero-based indexing: fib(0) = 0, fib(1) = 1. - For n >= 2,...
Count Enclosed Islands in a Grid
This question evaluates grid traversal and graph concepts such as connected-component detection, boundary-condition reasoning, and algorithmic time/sp...
Implement factorial and count trailing zeros
Answer the following coding questions in Python. 1) Implement factorial Implement a function factorial(n) that returns \(n!\) for a non-negative integ...
Detect earliest collision among moving cars
You are given n vehicles with kinematics parameters. A “collision” means two vehicles occupy the same position at the same time. Assume continuous tim...
Assign 2n Workers to Two Tasks to Minimize Total Time
You manage 2n workers and two tasks, A and B. Every worker must be assigned to exactly one task, and each task must be staffed by exactly n workers. W...
Implement Fibonacci with efficiency constraints
Write a function fib(n) that returns the nth Fibonacci number (0-indexed: fib(0)=0, fib(1)=1). Requirements: - Handle n up to at least 10^6. - Discuss...
How do you expand nested placeholders in strings?
You are given a dictionary of string templates. Keys are identifiers like X, Y, Z. A template may contain placeholders of the form %KEY%, which should...
Compute probability of random arithmetic progression triple
You have the integers from 1 to 30 inclusive. You randomly choose 3 distinct numbers without replacement, and all 3-element subsets are equally likely...
Implement Univariate Linear Regression with Ordinary Least Squares
Implement univariate (simple) linear regression fitted in batch with the ordinary least squares (OLS) closed-form solution. You must implement the for...