How often are these problems asked?
Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent tcs interviews.
Very Likely
75-100%
Likely
50-74%
Sometimes
25-49%
Rare
0-24%
Problem database last updated: June 20, 2025
100 problems · 50 Easy, 45 Medium, 5 Hard · Ranked #12 of 458
50 Easy
50% · avg 23%
45 Medium
45% · avg 59%
5 Hard
5% · avg 18%
Based on 100 reported problems, tcs interviews are easier than average - only 5% Hard compared to 18% across all companies.
Compared to the industry average, tcs puts unusual emphasis on database (7% of problems, 6.2x the industry average), string-matching (2% of problems, 2.3x the industry average), memoization (3% of problems, 1.9x the industry average). If you're short on time, these are the categories to double down on.
The most common topics are array (57%), string (22%), math (20%), two-pointers (20%). Problems below are sorted by frequency, the ones at the top are asked most often.
| Problem | Difficulty | Frequency | Topics | |
|---|---|---|---|---|
Two Sum Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target. | Easy | Very Likely | arrayhash-map | Solve |
Palindrome Number Given an integer x, return true if x is a palindrome, and false otherwise. | Easy | Very Likely | math | Solve |
Majority Element Given an array nums of size n, return the majority element. | Easy | Likely | arrayhash-tabledivide-and-conquer | Solve |
Best Time to Buy and Sell Stock You are given an array prices where prices[i] is the price of a given stock on the ith day. | Easy | Likely | arraydynamic-programming | Solve |
Maximum Subarray Given an integer array nums, find the subarray with the largest sum, and return its sum. | Medium | Likely | arraydivide-and-conquerdynamic-programming | Solve |
Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. | Easy | Likely | arraystringtrie | Solve |
Valid Parentheses Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. | Easy | Likely | stringstack | Solve |
Rotate Array Given an integer array nums, rotate the array to the right by k steps, where k is non-negative. | Medium | Likely | arraymathtwo-pointers | Solve |
Fibonacci Number The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, startin... | Easy | Likely | mathdynamic-programmingrecursion | Solve |
Subarray Sum Equals K Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. | Medium | Likely | arrayhash-tableprefix-sum | Solve |
Move Zeroes Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. | Easy | Likely | arraytwo-pointers | Solve |
Reverse Integer Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1... | Medium | Likely | math | Solve |
Maximum Ascending Subarray Sum Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums. | Easy | Likely | array | Solve |
Jump Game You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length... | Medium | Likely | arraydynamic-programminggreedy | Solve |
Count the Digits That Divide a Number Given an integer num, return the number of digits in num that divide num. | Easy | Likely | math | Solve |
Palindrome Partitioning IV Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false. | Hard | Likely | stringdynamic-programming | Solve |
Remove Letter To Equalize Frequency You are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from word so th... | Easy | Likely | hash-tablestringcounting | Solve |
Minimum Cuts to Divide a Circle A valid cut in a circle can be: | Easy | Likely | mathgeometry | Solve |
Minimum Operations to Exceed Threshold Value I You are given a 0-indexed integer array nums, and an integer k. | Easy | Likely | array | Solve |
Merge Sorted Array You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and num... | Easy | Likely | arraytwo-pointerssorting | Solve |
Minimum Operations to Exceed Threshold Value II You are given a 0-indexed integer array nums, and an integer k. | Medium | Likely | arrayheap-priority-queuesimulation | Solve |
Valid Anagram Given two strings s and t, return true if t is an anagram of s, and false otherwise. | Easy | Likely | hash-tablestringsorting | Solve |
Single Number Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. | Easy | Likely | arraybit-manipulation | Solve |
Unique Paths There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner... | Medium | Likely | mathdynamic-programmingcombinatorics | Solve |
Roman to Integer Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. | Easy | Likely | hash-tablemathstring | Solve |
Bitwise ORs of Subarrays Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr. | Medium | Likely | arraydynamic-programmingbit-manipulation | Solve |
3Sum Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. | Medium | Likely | arraytwo-pointerssorting | Solve |
Climbing Stairs You are climbing a staircase. It takes n steps to reach the top. | Easy | Likely | mathdynamic-programmingmemoization | Solve |
Find the Index of the First Occurrence in a String Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. | Easy | Likely | two-pointersstringstring-matching | Solve |
Longest Palindromic Substring Given a string s, return the longest palindromic substring in s. | Medium | Likely | two-pointersstringdynamic-programming | Solve |
Remove Duplicates from Sorted Array 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 o... | Easy | Likely | arraytwo-pointers | Solve |
Second Highest Salary Table: Employee | Medium | Sometimes | database | Solve |
Plus One You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most sig... | Easy | Sometimes | arraymath | Solve |
Container With Most Water You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). | Medium | Sometimes | arraytwo-pointersgreedy | Solve |
Pow(x, n) Implement pow(x, n), which calculates x raised to the power n (i.e., xn). | Medium | Sometimes | mathrecursion | Solve |
Sort Colors Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order... | Medium | Sometimes | arraytwo-pointerssorting | Solve |
Length of Last Word Given a string s consisting of words and spaces, return the length of the last word in the string. | Easy | Sometimes | string | Solve |
Happy Number Write an algorithm to determine if a number n is happy. | Easy | Sometimes | hash-tablemathtwo-pointers | Solve |
Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. | Hard | Sometimes | arraytwo-pointersdynamic-programming | Solve |
Missing Number Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. | Easy | Sometimes | arrayhash-tablemath | Solve |
Reverse Words in a String Given an input string s, reverse the order of the words. | Medium | Sometimes | two-pointersstring | Solve |
Contains Duplicate Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. | Easy | Sometimes | arrayhash-tablesorting | Solve |
Sliding Window Maximum 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. You can only see... | Hard | Sometimes | arrayqueuesliding-window | Solve |
Spiral Matrix Given an m x n matrix, return all elements of the matrix in spiral order. | Medium | Sometimes | arraymatrixsimulation | Solve |
Toeplitz Matrix Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. | Easy | Sometimes | arraymatrix | Solve |
Best Time to Buy and Sell Stock II You are given an integer array prices where prices[i] is the price of a given stock on the ith day. | Medium | Sometimes | arraydynamic-programminggreedy | Solve |
Sqrt(x) Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. | Easy | Sometimes | mathbinary-search | Solve |
Merge Two Sorted Lists You are given the heads of two sorted linked lists list1 and list2. | Easy | Sometimes | linked-listrecursion | Solve |
Set Matrix Zeroes Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's. | Medium | Sometimes | arrayhash-tablematrix | Solve |
Max Consecutive Ones III 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. | Medium | Sometimes | arraybinary-searchsliding-window | Solve |
Check if Array Is Sorted and Rotated Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise,... | Easy | Sometimes | array | Solve |
Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without duplicate characters. | Medium | Sometimes | hash-tablestringsliding-window | Solve |
Add Two Numbers You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a sing... | Medium | Sometimes | linked-listmathrecursion | Solve |
Department Top Three Salaries Table: Employee | Hard | Sometimes | database | Solve |
Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. | Medium | Sometimes | stringdynamic-programmingbacktracking | Solve |
N-th Tribonacci Number The Tribonacci sequence Tn is defined as follows: | Easy | Sometimes | mathdynamic-programmingmemoization | Solve |
Single Element in a Sorted Array You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. | Medium | Sometimes | arraybinary-search | Solve |
Add Binary Given two binary strings a and b, return their sum as a binary string. | Easy | Sometimes | mathstringbit-manipulation | Solve |
4Sum Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: | Medium | Sometimes | arraytwo-pointerssorting | Solve |
Article Views I Table: Views | Easy | Sometimes | database | Solve |
Find Customer Referee Table: Customer | Easy | Sometimes | database | Solve |
K-diff Pairs in an Array Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array. | Medium | Sometimes | arrayhash-tabletwo-pointers | Solve |
Reverse Linked List Given the head of a singly linked list, reverse the list, and return the reversed list. | Easy | Sometimes | linked-listrecursion | Solve |
Fizz Buzz Given an integer n, return a string array answer (1-indexed) where: | Easy | Sometimes | mathstringsimulation | Solve |
Reverse String Write a function that reverses a string. The input string is given as an array of characters s. | Easy | Sometimes | two-pointersstring | Solve |
Same Tree Given the roots of two binary trees p and q, write a function to check if they are the same or not. | Easy | Sometimes | treedepth-first-searchbreadth-first-search | Solve |
Largest Number Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. | Medium | Sometimes | arraystringgreedy | Solve |
Find First and Last Position of Element in Sorted Array Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. | Medium | Sometimes | arraybinary-search | Solve |
Next Permutation A permutation of an array of integers is an arrangement of its members into a sequence or linear order. | Medium | Sometimes | arraytwo-pointers | Solve |
Pascal's Triangle Given an integer numRows, return the first numRows of Pascal's triangle. | Easy | Sometimes | arraydynamic-programming | Solve |
Sort Array by Increasing Frequency Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them... | Easy | Sometimes | arrayhash-tablesorting | Solve |
Edit Distance Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. | Medium | Sometimes | stringdynamic-programming | Solve |
Binary Search Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then ret... | Easy | Sometimes | arraybinary-search | Solve |
Longest Common Subsequence Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. | Medium | Sometimes | stringdynamic-programming | Solve |
Remove Duplicates from Sorted Array II Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative or... | Medium | Sometimes | arraytwo-pointers | Solve |
Subsets Given an integer array nums of unique elements, return all possible subsets (the power set). | Medium | Sometimes | arraybacktrackingbit-manipulation | Solve |
Largest Rectangle in Histogram Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the his... | Hard | Sometimes | arraystackmonotonic-stack | Solve |
Rotate String Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. | Easy | Sometimes | stringstring-matching | Solve |
Longest Consecutive Sequence Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. | Medium | Sometimes | arrayhash-tableunion-find | Solve |
Maximum Product Subarray Given an integer array nums, find a subarray that has the largest product, and return the product. | Medium | Sometimes | arraydynamic-programming | Solve |
Employee Bonus Table: Employee | Easy | Sometimes | database | Solve |
Sort Characters By Frequency Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the st... | Medium | Sometimes | hash-tablestringsorting | Solve |
Power of Two Given an integer n, return true if it is a power of two. Otherwise, return false. | Easy | Sometimes | mathbit-manipulationrecursion | Solve |
Search a 2D Matrix II Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: | Medium | Sometimes | arraybinary-searchdivide-and-conquer | Solve |
Sum of Unique Elements You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. | Easy | Sometimes | arrayhash-tablecounting | Solve |
Number of Employees Who Met the Target There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company. | Easy | Sometimes | array | Solve |
Big Countries Table: World | Easy | Sometimes | database | Solve |
Path with Maximum Probability You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the node... | Medium | Sometimes | arraygraphheap-priority-queue | Solve |
Combination Sum Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum... | Medium | Sometimes | arraybacktracking | Solve |
Word Search Given an m x n grid of characters board and a string word, return true if word exists in the grid. | Medium | Sometimes | arraystringbacktracking | Solve |
Partition List Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. | Medium | Sometimes | linked-listtwo-pointers | Solve |
3Sum Closest Given an integer array nums of length n and an integer target, find three integers at distinct indices in nums such that the sum is closest to target. | Medium | Sometimes | arraytwo-pointerssorting | Solve |
How Many Numbers Are Smaller Than the Current Number Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of val... | Easy | Sometimes | arrayhash-tablesorting | Solve |
Peak Index in a Mountain Array You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease. | Medium | Sometimes | arraybinary-search | Solve |
Count Primes Given an integer n, return the number of prime numbers that are strictly less than n. | Medium | Sometimes | arraymathenumeration | Solve |
Product of Array Except Self Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. | Medium | Sometimes | arrayprefix-sum | Solve |
Coin Change You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. | Medium | Sometimes | arraydynamic-programmingbreadth-first-search | Solve |
Students and Examinations Table: Students | Easy | Sometimes | database | Solve |
Intersection of Two Arrays Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any... | Easy | Sometimes | arrayhash-tabletwo-pointers | Solve |
First Unique Character in a String Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. | Easy | Sometimes | hash-tablestringqueue | Solve |
Two Sum
SolveGiven an array of integers nums and an integer target, return the indices of the two numbers that add up to target.
Palindrome Number
SolveGiven an integer x, return true if x is a palindrome, and false otherwise.
Majority Element
SolveGiven an array nums of size n, return the majority element.
Best Time to Buy and Sell Stock
SolveYou are given an array prices where prices[i] is the price of a given stock on the ith day.
Maximum Subarray
SolveGiven an integer array nums, find the subarray with the largest sum, and return its sum.
Longest Common Prefix
SolveWrite a function to find the longest common prefix string amongst an array of strings.
Valid Parentheses
SolveGiven a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
Rotate Array
SolveGiven an integer array nums, rotate the array to the right by k steps, where k is non-negative.
Fibonacci Number
SolveThe Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, startin...
Subarray Sum Equals K
SolveGiven an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
Move Zeroes
SolveGiven an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Reverse Integer
SolveGiven a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1...
Maximum Ascending Subarray Sum
SolveGiven an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.
Jump Game
SolveYou are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length...
Count the Digits That Divide a Number
SolveGiven an integer num, return the number of digits in num that divide num.
Palindrome Partitioning IV
SolveGiven a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.
Remove Letter To Equalize Frequency
SolveYou are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from word so th...
Minimum Operations to Exceed Threshold Value I
SolveYou are given a 0-indexed integer array nums, and an integer k.
Merge Sorted Array
SolveYou are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and num...
Minimum Operations to Exceed Threshold Value II
SolveYou are given a 0-indexed integer array nums, and an integer k.
Valid Anagram
SolveGiven two strings s and t, return true if t is an anagram of s, and false otherwise.
Single Number
SolveGiven a non-empty array of integers nums, every element appears twice except for one. Find that single one.
Unique Paths
SolveThere is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner...
Roman to Integer
SolveRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Bitwise ORs of Subarrays
SolveGiven an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr.
3Sum
SolveGiven an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Climbing Stairs
SolveYou are climbing a staircase. It takes n steps to reach the top.
Find the Index of the First Occurrence in a String
SolveGiven two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Longest Palindromic Substring
SolveGiven a string s, return the longest palindromic substring in s.
Remove Duplicates from Sorted Array
SolveGiven 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 o...
Plus One
SolveYou are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most sig...
Container With Most Water
SolveYou are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).
Pow(x, n)
SolveImplement pow(x, n), which calculates x raised to the power n (i.e., xn).
Sort Colors
SolveGiven an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order...
Length of Last Word
SolveGiven a string s consisting of words and spaces, return the length of the last word in the string.
Happy Number
SolveWrite an algorithm to determine if a number n is happy.
Trapping Rain Water
SolveGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Missing Number
SolveGiven an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
Reverse Words in a String
SolveGiven an input string s, reverse the order of the words.
Contains Duplicate
SolveGiven an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
Sliding Window Maximum
SolveYou 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. You can only see...
Spiral Matrix
SolveGiven an m x n matrix, return all elements of the matrix in spiral order.
Toeplitz Matrix
SolveGiven an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false.
Best Time to Buy and Sell Stock II
SolveYou are given an integer array prices where prices[i] is the price of a given stock on the ith day.
Sqrt(x)
SolveGiven a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.
Merge Two Sorted Lists
SolveYou are given the heads of two sorted linked lists list1 and list2.
Set Matrix Zeroes
SolveGiven an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.
Max Consecutive Ones III
SolveGiven 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.
Check if Array Is Sorted and Rotated
SolveGiven an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise,...
Longest Substring Without Repeating Characters
SolveGiven a string s, find the length of the longest substring without duplicate characters.
Add Two Numbers
SolveYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a sing...
Generate Parentheses
SolveGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
N-th Tribonacci Number
SolveThe Tribonacci sequence Tn is defined as follows:
Single Element in a Sorted Array
SolveYou are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.
Add Binary
SolveGiven two binary strings a and b, return their sum as a binary string.
4Sum
SolveGiven an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:
K-diff Pairs in an Array
SolveGiven an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.
Reverse Linked List
SolveGiven the head of a singly linked list, reverse the list, and return the reversed list.
Fizz Buzz
SolveGiven an integer n, return a string array answer (1-indexed) where:
Reverse String
SolveWrite a function that reverses a string. The input string is given as an array of characters s.
Same Tree
SolveGiven the roots of two binary trees p and q, write a function to check if they are the same or not.
Largest Number
SolveGiven a list of non-negative integers nums, arrange them such that they form the largest number and return it.
Find First and Last Position of Element in Sorted Array
SolveGiven an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.
Next Permutation
SolveA permutation of an array of integers is an arrangement of its members into a sequence or linear order.
Pascal's Triangle
SolveGiven an integer numRows, return the first numRows of Pascal's triangle.
Sort Array by Increasing Frequency
SolveGiven an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them...
Edit Distance
SolveGiven two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.
Binary Search
SolveGiven an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then ret...
Longest Common Subsequence
SolveGiven two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.
Remove Duplicates from Sorted Array II
SolveGiven an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative or...
Subsets
SolveGiven an integer array nums of unique elements, return all possible subsets (the power set).
Largest Rectangle in Histogram
SolveGiven an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the his...
Rotate String
SolveGiven two strings s and goal, return true if and only if s can become goal after some number of shifts on s.
Longest Consecutive Sequence
SolveGiven an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Maximum Product Subarray
SolveGiven an integer array nums, find a subarray that has the largest product, and return the product.
Sort Characters By Frequency
SolveGiven a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the st...
Power of Two
SolveGiven an integer n, return true if it is a power of two. Otherwise, return false.
Search a 2D Matrix II
SolveWrite an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties:
Sum of Unique Elements
SolveYou are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.
Number of Employees Who Met the Target
SolveThere are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company.
Path with Maximum Probability
SolveYou are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the node...
Combination Sum
SolveGiven an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum...
Word Search
SolveGiven an m x n grid of characters board and a string word, return true if word exists in the grid.
Partition List
SolveGiven the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
3Sum Closest
SolveGiven an integer array nums of length n and an integer target, find three integers at distinct indices in nums such that the sum is closest to target.
How Many Numbers Are Smaller Than the Current Number
SolveGiven the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of val...
Peak Index in a Mountain Array
SolveYou are given an integer mountain array arr of length n where the values increase to a peak element and then decrease.
Count Primes
SolveGiven an integer n, return the number of prime numbers that are strictly less than n.
Product of Array Except Self
SolveGiven an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
Coin Change
SolveYou are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Intersection of Two Arrays
SolveGiven two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any...
First Unique Character in a String
SolveGiven a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent tcs interviews.
Very Likely
75-100%
Likely
50-74%
Sometimes
25-49%
Rare
0-24%
tcs interviews focus heavily on array, string, math problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.
Beyond solving problems, practice explaining your approach. tcs interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.
Looking for more companies? Browse all 458 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.
tcs has been reported to ask 100 distinct coding problems. The most common topics are array, string, math. 50 are Easy difficulty, 45 are Medium, and 5 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.
Based on 100 reported problems, tcs interviews are easier than average - only 5% Hard compared to 18% across all companies. 45% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.
Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, math. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.
Simulate a real tcs coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.
Simulate a tcs interview with AIarrow_forward