Question Bank

Coding & Algorithms interview questions

An algorithm interview requires more than working code: explain why the solution is correct. Start with examples and constraints, then choose a data structure and estimate complexity. Check empty inputs, repeated values and boundary cases.

1635
questions
16
categories
50
companies

Showing 20 of 44 questions

EasyCoding & Algorithms

Given a 2D grid (image), a starting point (sr, sc), and a new color, implement flood fill: recolor the starting pixel and all connected pixels of the same color (4-directional).

coding
Practice in bot
MediumCoding & Algorithms

Write a class for weighted random sampling. The class accepts an array of (item, probability) pairs, and its sample() method returns an item according to that distribution.

coding
Practice in bot
HardCoding & Algorithms

Implement weighted random sampling with O(1) query time using the Alias Method.

samplingalias methodprobability
Practice in bot
MediumCoding & AlgorithmsSilver Mont

Implement sampling from a discrete distribution specified by a histogram that may contain floating-point weights. Optimize it to O(log n) per query.

coding
Practice in bot
MediumCoding & Algorithms

For each number in array B, find the number in array A that maximizes their XOR. Implement a naive solution, then optimize it.

coding
Practice in bot
EasyCoding & AlgorithmsPulsePoint

Write a function that, given the mean of five numbers and one of those numbers, returns the mean of the remaining four.

coding
Practice in bot
MediumCoding & AlgorithmsConstructor

Implement a Bloom filter. Explain how it works and write the code.

coding
Practice in bot
MediumCoding & AlgorithmsConstructor

A Bloom filter has a false positive rate. How does it depend on parameters (array size m, number of hash functions k, number of elements n)? How to choose optimal parameters?

bloom filterprobabilityhashing
Practice in bot
MediumCoding & AlgorithmsConstructor

Compare Bloom filter vs hash set. When is Bloom filter preferable? Give real-world examples.

bloom filterhash mapdata structures
Practice in bot
EasyCoding & Algorithms

Given an array of integers and a target value, find two numbers that add up to target and return their indices.

arrayshash-table
Practice in bot
EasyCoding & Algorithms

Given a string containing '(', ')', '{', '}', '[', ']', determine if the input string has valid brackets.

stringsstack
Practice in bot
EasyCoding & Algorithms

Given a sorted and rotated array, find the minimum element in O(log n).

binary-searcharrays
Practice in bot
EasyCoding & Algorithms

Merge two sorted linked lists into one sorted linked list.

linked-listtwo-pointers
Practice in bot
EasyCoding & Algorithms

Find the k-th largest element in an unsorted array.

arrayssortingheap
Practice in bot
MediumCoding & Algorithms

Design and implement an LRU (Least Recently Used) Cache with O(1) get and put.

hash-tablelinked-listdesign
Practice in bot
MediumCoding & Algorithms

Given an array of intervals, merge all overlapping intervals.

arrayssortingintervals
Practice in bot
MediumCoding & Algorithms

Find the diameter of a binary tree (longest path between any two nodes).

treesdfsrecursion
Practice in bot
MediumCoding & Algorithms

Given a 2D grid of '1's and '0's, count the number of islands (connected components of 1s).

graphsbfsdfsmatrix
Practice in bot
MediumCoding & Algorithms

Implement a Trie (prefix tree) with insert, search, and startsWith operations.

treesstringsdesign
Practice in bot
MediumCoding & Algorithms

Find the length of the longest increasing subsequence (LIS) in an array.

dpbinary-search
Practice in bot

Prepare for your next interview with Vibe Interview.

Download Vibe Interview
Coding & Algorithms interview questions | Vibe Interview