Practice DSA interview questions

2000+ data structures and algorithms problems, tagged by company and difficulty. Browse the full bank free, then log in to solve, track progress and see detailed solutions.

Difficulty

Category

701 questions

Fault-Tolerant Data Transmission

EasyTwo Pointers

A network packet is received. It might contain exactly one corrupted bit. Verify if the packet string can be a valid palindrome if you are allowed to delete at most one character.

AirbnbDatabricksJP Morgan Chase

Mutual Friends Finder

EasyTwo Pointers

A social network graph returns two unsorted arrays of friend IDs for User A and User B. Return an array of their mutual friends (the intersection of the arrays).

AdobeAtlassianPlaid

Collaborative Text Editor Resolution

EasyTwo Pointers

Google Docs resolves two users typing. They type characters and backspaces '#'. Given two strings containing '#' representing backspaces, determine if the final typed results are equal.

AmazonDatabricksOracle

Signal Processing Amplitude Sorting

EasyTwo Pointers

A DSP chip outputs an array of signal amplitudes sorted in non-decreasing order (can contain negatives). Return an array of the squares of each amplitude, also sorted in non-decreasing order.

AdobeCREDElastic

Complex Financial Transaction Reconciliation

MediumTwo Pointers

A bank needs to identify complex fraud rings. Given an array of transaction amounts and a target amount, return all unique quadruplets of transactions that sum exactly to the target.

RipplingSamsung R&DWalmart Global Tech

Data Retention Policy Enforcement

EasyTwo Pointers

An array holds user IDs. A data purge requires removing all instances of a specific 'banned_id' in-place. Return the number of valid IDs remaining. Order doesn't matter.

AirbnbPlaidWalmart Global Tech

Database Primary Key Collision

MediumTwo Pointers

A table array has N+1 records with IDs from 1 to N. Due to a replication error, exactly one ID appears multiple times. Find the duplicate ID without modifying the array, using O(1) space.

AdobeAtlassianGoldman Sachs

Resource Allocation Matcher

EasyTwo Pointers

You have an array of server capacities and an array of task requirements. Assign tasks to servers such that requirement <= capacity. Maximize tasks assigned.

JP Morgan ChasePostmanStripe

String Compression Decoder

MediumTwo Pointers

A URL shortening service uses basic compression. Given a compressed string like 'a2b3', decompress it or verify its length compared to the original constraint.

HasuraMongoDBSnowflake

Valid Triangle Number Combinations

MediumTwo Pointers

A 3D rendering engine needs to form triangles from an array of edge lengths. Find the number of valid triplets that can form a triangle (sum of two smallest sides > largest side).

OktaOracleVMware (Broadcom)

Maximum Average Subarray I

EasySliding Window

Given an integer array nums consisting of n elements, and an integer k. Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value.

BrowserStackElasticOracle

Sliding Window Maximum

HardSliding Window

You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. Return the max sliding window.

AtlassianGoldman SachsGrafana Labs

Max Consecutive Ones III

MediumSliding Window

Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.

ElasticMicrosoftSalesforce India

Minimum Size Subarray Sum

MediumSliding Window

Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray of which the sum is greater than or equal to target.

AirbnbAmazonQualcomm

Frequency of the Most Frequent Element

MediumSliding Window

The frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index and increment the element at that index by 1. Return the maximum possible frequency of an element after performing at most k operations.

BrowserStackOracleSalesforce India

Subarray Product Less Than K

MediumSliding Window

Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.

AmazonAtlassianBrowserStack

Longest Repeating Character Replacement

MediumSliding Window

You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times. Return the length of the longest substring containing the same letter you can get.

Cisco IndiaSamsung R&DVMware (Broadcom)

Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold

MediumSliding Window

Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.

AtlassianHasuraMongoDB

Contains Duplicate II

EasySliding Window

Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.

AtlassianGoldman SachsSamsung R&D

Maximum Points You Can Obtain from Cards

MediumSliding Window

There are several cards arranged in a row, and each card has an associated number of points. You can take exactly k cards from either the beginning or the end of the row. Return the maximum score you can obtain.

AmazonFlipkartStripe

Longest Subarray of 1s After Deleting One Element

MediumSliding Window

Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulting array.

Grafana LabsJP Morgan ChasePlaid

Find K-Length Substrings With No Repeated Characters

MediumSliding Window

Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters.

Grafana LabsQualcommRippling

Maximum Number of Vowels in a Substring of Given Length

MediumSliding Window

Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.

FlipkartMicrosoftVMware (Broadcom)

Minimum Swaps to Group All 1's Together

MediumSliding Window

Given a binary array data, return the minimum number of swaps required to group all 1's present in the array together in any place in the array.

AmazonCisco IndiaDatabricks

Grumpy Bookstore Owner

MediumSliding Window

There is a bookstore owner that has a store open for n minutes. You are given an array customers and a binary array grumpy. The owner can use a secret technique to not be grumpy for minutes consecutive minutes. Return the maximum number of customers that can be satisfied.

GitLabTwilioWalmart Global Tech

Fruit Into Baskets

MediumSliding Window

You are visiting a farm that has a single row of fruit trees arranged from left to right. You have two baskets, and each basket can hold only one type of fruit. Return the maximum number of fruits you can pick.

GooglePlaidSwiggy

Valid Palindrome

EasyTwo Pointers

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Given a string s, return true if it is a palindrome.

DatabricksSwiggyVMware (Broadcom)

Remove Duplicates from Sorted Array

EasyTwo Pointers

Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same.

Cisco IndiaSalesforce IndiaSnowflake

Move Zeroes

EasyTwo Pointers

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. You must do this in-place.

AdobeGoogleRubrik

Is Subsequence

EasyTwo Pointers

Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string generated from the original string with some characters deleted without changing relative order.

AirbnbElasticFlipkart