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.

335 Questions 80 Companies08.08.2026
Showing 20 results
Role
Uber logo
Uber
Medium
Data Scientist

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. ...

Coding & Algorithms
4
1
55 people solved
Feb 1, 2026
Citadel logo
Citadel
Hard
Data Scientist

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...

Coding & Algorithms
4
0
79 people solved
Jan 30, 2026
Virtu logo
Virtu
Medium
Data Scientist

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 ...

Coding & Algorithms
3
0
23 people solved
Jan 22, 2026
Uber logo
Uber
Medium
Data Scientist Locked

Move zeros to front

This question evaluates array manipulation and in-place algorithm skills, specifically competency in stable element reordering, index management, and ...

Coding & Algorithms
4
0
31 people solved
Jan 18, 2026
Boston logo
Boston
Easy
Data Scientist

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 ...

Coding & Algorithms
5
0
46 people solved
Jan 17, 2026
Others logo
Others
Easy
Data Scientist

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 ...

Coding & Algorithms
1
0
29 people solved
Jan 17, 2026
Uber logo
Uber
Medium
Data Scientist

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...

Coding & Algorithms
10
0
77 people solved
Jan 14, 2026
Pinterest logo
Pinterest
Medium
Data Scientist Locked

Implement Jackknife and Random Choice

This question evaluates understanding of statistical resampling (jackknife), probabilistic sampling algorithms including with- and without-replacement...

Coding & Algorithms
8
0
91 people solved
Jan 11, 2026
Bytedance logo
Bytedance
Hard
Data Scientist

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...

Coding & Algorithms
2
0
39 people solved
Jan 10, 2026
Thumbtack logo
Thumbtack
Medium
Data Scientist

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...

Coding & Algorithms
0
0
5 people solved
Jan 9, 2026
Oracle logo
Oracle
Medium
Data Scientist

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...

Coding & Algorithms
2
0
28 people solved
Jan 9, 2026
Plymouth Rock Assurance Corporation logo
Plymouth Rock Assurance Corporation
Medium
Data ScientistIntern

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,...

Coding & Algorithms
1
0
19 people solved
Jan 3, 2026
Oracle logo
Oracle
Medium
Data ScientistIntern Locked

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...

Coding & Algorithms
3
0
29 people solved
Jan 3, 2026
Upstart logo
Upstart
Easy
Data Scientist

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...

Coding & Algorithms
8
0
139 people solved
Dec 9, 2025
Meta logo
Meta
Medium
Data Scientist

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...

Coding & Algorithms
4
0
30 people solved
Dec 4, 2025
Two Sigma logo
Two Sigma
Hard
Data Scientist

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...

Coding & Algorithms
0
0
7 people solved
Nov 28, 2025
Google logo
Google
Medium
Data ScientistSenior+

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...

Coding & Algorithms
6
0
56 people solved
Nov 24, 2025
Meta logo
Meta
Medium
Data Scientist

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...

Coding & Algorithms
3
0
35 people solved
Nov 24, 2025
Mavensecurities logo
Mavensecurities
Medium
Data Scientist

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...

Coding & Algorithms
1
0
23 people solved
Nov 20, 2025
Two Sigma logo
Two Sigma
Hard
Data ScientistIntern

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...

Coding & Algorithms
0
0
4 people solved
Nov 15, 2025

Explore more Data Scientist Coding & Algorithms interview questions

Real questions from candidate reports, grouped by company, topic and role.

By company
Other categories for Data Scientist
Coding & Algorithms questions for other roles
Browse all