
Paytm


20+ Paytm Full Stack Developer Interview Questions and Answers
Q1. Factorial Calculation Problem Statement
Develop a program to compute the factorial of a given integer 'n'.
The factorial of a non-negative integer 'n', denoted as n!
, is the product of all positive integers les...read more
Program to compute factorial of a given integer 'n', with error handling for negative values.
Create a function to calculate factorial using a loop or recursion
Check if input is negative, return 'Error' if true
Handle edge cases like 0 and 1 separately
Return the calculated factorial value
Q2. Count Ways to Reach the N-th Stair Problem Statement
You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two step...read more
The task is to find the number of distinct ways to climb from the 0th step to the Nth step, where each time you can climb either one step or two steps.
Use dynamic programming to solve this problem
Create an array to store the number of ways to reach each step
Initialize the first two elements of the array as 1 and 2
For each subsequent step, the number of ways to reach that step is the sum of the number of ways to reach the previous two steps
Return the number of ways to reach th...read more
Q3. Sub Sort Problem Statement
You are given an integer array ARR
. Determine the length of the shortest contiguous subarray which, when sorted in ascending order, results in the entire array being sorted in ascendi...read more
Determine the length of the shortest contiguous subarray that needs to be sorted to make the entire array sorted in ascending order.
Iterate from left to right to find the first element out of order.
Iterate from right to left to find the last element out of order.
Calculate the length of the subarray between the two out of order elements.
Q4. Ceil Value from BST Problem Statement
Given a Binary Search Tree (BST) and an integer, write a function to return the ceil value of a particular key in the BST.
The ceil of an integer is defined as the smallest...read more
Ceil value of a key in a Binary Search Tree (BST) is the smallest integer greater than or equal to the given number.
Traverse the BST to find the closest integer greater than or equal to the given key.
Compare the key with the current node value and update the ceil value accordingly.
Recursively traverse left or right subtree based on the key value to find the ceil value.
Return the ceil value once found for each test case.
Q5. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an integer array containing only 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of 0s, 1s, and 2s while traversing the array.
Swap elements based on the values encountered to sort the array in-place.
Time complexity should be O(N) to solve the problem efficiently.
Q6. Next Greater Element Problem Statement
Given a list of integers of size N
, your task is to determine the Next Greater Element (NGE) for every element. The Next Greater Element for an element X
is the first elem...read more
The task is to find the Next Greater Element for each element in a list of integers.
Iterate through the list of integers from right to left
Use a stack to keep track of elements whose NGE is yet to be found
Pop elements from the stack until a greater element is found or the stack is empty
Assign the NGE as the top element of the stack or -1 if the stack is empty
Q7. Cousin Nodes in a Binary Tree
Determine if two nodes in a binary tree are cousins. Nodes are considered cousins if they are at the same level and have different parents.
Explanation:
In a binary tree, each node...read more
Determine if two nodes in a binary tree are cousins based on level and parent nodes.
Traverse the binary tree to find the levels and parents of the given nodes.
Check if the nodes are at the same level and have different parents to determine if they are cousins.
Return 'YES' if the nodes are cousins, 'NO' otherwise.
Example: For input '1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1' and nodes 4 7, output is 'YES'.
Q8. Odd Even Levels in Binary Tree
Given a binary tree, the task is to compute the modulus of the difference between the sum of nodes at odd levels and the sum of nodes at even levels.
Input:
The first line contain...read more
The task is to compute the modulus of the difference between the sum of nodes at odd levels and the sum of nodes at even levels in a binary tree.
Traverse the binary tree level by level and calculate the sum of nodes at odd and even levels separately.
Find the absolute difference between the sums and return the modulus of this difference.
Handle null nodes by skipping them during the sum calculation.
Q9. Minimum Characters to Make a String Palindrome
Given a string STR
of length N
, determine the minimum number of characters to be added to the front of the string to make it a palindrome.
Input:
The first line co...read more
The task is to find the minimum number of characters needed to be added to the front of a string to make it a palindrome.
Iterate through the string from both ends and count the number of characters that need to be added to make it a palindrome.
Use two pointers approach to compare characters from start and end of the string.
Keep track of the count of characters needed to be added to form a palindrome.
Q10. Rotate Matrix by 90 Degrees Problem Statement
Given a square matrix 'MATRIX' of non-negative integers, rotate the matrix by 90 degrees in an anti-clockwise direction using only constant extra space.
Input:
The ...read more
Rotate a square matrix by 90 degrees in an anti-clockwise direction using constant extra space.
Iterate through each layer of the matrix from outer to inner layers
Swap elements in groups of 4 to rotate the matrix
Handle odd-sized matrices by adjusting the center element if needed
Q11. LCA in a Binary Search Tree
You are given a binary search tree (BST) containing N nodes. Additionally, you have references to two nodes, P and Q, within this BST.
Your task is to determine the Lowest Common Anc...read more
Find the Lowest Common Ancestor (LCA) of two nodes in a Binary Search Tree (BST).
Traverse the BST from the root node to find the LCA of the given nodes.
Compare the values of the nodes with the values of P and Q to determine the LCA.
If the values of P and Q are on opposite sides of the current node, then the current node is the LCA.
Q12. House Robber Problem Statement
Mr. X is a professional robber with a plan to rob houses arranged in a circular street. Each house has a certain amount of money hidden, separated by a security system that alerts...read more
The task is to find the maximum amount of money Mr. X can rob from houses arranged in a circle without alerting the police.
The problem can be solved using dynamic programming.
Create two arrays to store the maximum amount of money robbed when considering the first house and when not considering the first house.
Iterate through the array and update the maximum amount of money robbed at each house.
The final answer will be the maximum of the last element in both arrays.
Q13. Rotting Oranges Problem Statement
You are given a grid containing oranges where each cell of the grid can contain one of the three integer values:
- 0 - representing an empty cell
- 1 - representing a fresh orange...read more
Find the minimum time required to rot all fresh oranges in a grid.
Create a queue to store the rotten oranges and their time of rotting.
Iterate through the grid to find all rotten oranges and add them to the queue.
Simulate the rotting process by checking adjacent cells and updating their status.
Track the time taken to rot all fresh oranges and return the result.
Handle edge cases like unreachable fresh oranges or already rotten oranges.
Q14. Subtree of Another Tree Problem Statement
Given two binary trees, T and S, determine whether S is a subtree of T. The tree S should have the same structure and node values as a subtree of T.
Explanation:
A subt...read more
Determine if one binary tree is a subtree of another binary tree based on their structure and node values.
Traverse through the main tree and check if any subtree matches the second tree
Use recursion to compare nodes of both trees
Handle edge cases like empty trees or null nodes
Check if the root node of the second tree exists in the main tree
Q15. Kth Smallest and Largest Element Problem Statement
You are provided with an array 'Arr' containing 'N' distinct integers and a positive integer 'K'. Your task is to find the Kth smallest and Kth largest element...read more
Find the Kth smallest and largest elements in an array.
Sort the array to easily find the Kth smallest and largest elements.
Ensure K is within the array's size to avoid errors.
Handle multiple test cases efficiently.
Consider edge cases like when N is small or K is at the extremes.
Q16. Search in a Row-wise and Column-wise Sorted Matrix Problem Statement
You are given an N * N matrix of integers where each row and each column is sorted in increasing order. Your task is to find the position of ...read more
Given a sorted N * N matrix, find the position of a target integer 'X'.
Iterate over rows and columns to search for the target integer 'X'.
Utilize the sorted nature of the matrix to optimize the search process.
Return the position of 'X' if found, else return '-1 -1'.
Q17. Problem Statement: Parity Move
You have an array of integers, and your task is to modify the array by moving all even numbers to the beginning while placing all odd numbers at the end. The order within even and...read more
Move all even numbers to the beginning and odd numbers to the end of an array.
Iterate through the array and swap even numbers to the front and odd numbers to the back.
Use two pointers, one starting from the beginning and one from the end, to achieve the desired arrangement.
Return the modified array with even numbers at the start and odd numbers at the end.
Q18. Anagram Pairs Verification Problem
Your task is to determine if two given strings are anagrams of each other. Two strings are considered anagrams if you can rearrange the letters of one string to form the other...read more
Determine if two strings are anagrams of each other by checking if they have the same characters in different order.
Create a character frequency map for both strings and compare them.
Sort both strings and compare if they are equal.
Use a hash table to store character counts and check if they are the same for both strings.
Q19. Find the Longest Palindromic Substring
Given a string ‘S’ composed of lowercase English letters, your task is to identify the longest palindromic substring within ‘S’.
If there are multiple longest palindromic ...read more
Find the longest palindromic substring in a given string, returning the rightmost one if multiple exist.
Iterate through each character in the string and expand around it to find palindromes
Keep track of the longest palindrome found and its starting index
Return the substring starting from the index of the longest palindrome found
Q20. Prerequisite Task Completion Verification
Given a positive integer 'N', representing the number of tasks, and a list of dependency pairs, determine if it is possible to complete all tasks considering these prer...read more
Determine if it is possible to complete all tasks considering prerequisites.
Create a graph representation of the tasks and dependencies.
Use topological sorting to check if there is a cycle in the graph.
Return 'Yes' if no cycle is found, 'No' otherwise.
Q21. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
Calculate the total amount of rainwater that can be trapped between given elevations in an array.
Iterate through the array and calculate the maximum height on the left and right of each bar.
Calculate the amount of water that can be trapped at each bar by taking the minimum of the maximum heights on the left and right.
Sum up the trapped water at each bar to get the total trapped water for the entire array.
Q22. Circular Move Problem Statement
You have a robot currently positioned at the origin (0, 0) on a two-dimensional grid, facing the north direction. You are given a sequence of moves in the form of a string of len...read more
Determine if a robot's movement path is circular on a 2D grid given a sequence of moves.
Iterate through the move sequence and update the robot's position based on the moves ('L' - turn left, 'R' - turn right, 'G' - move forward).
Check if the robot returns to the starting position after completing the move sequence.
If the robot ends up at the starting position and facing the north direction, the movement path is circular.
Q23. Bridge in Graph Problem Statement
Given an undirected graph with V vertices and E edges, your task is to find all the bridges in this graph. A bridge is an edge that, when removed, increases the number of conne...read more
Find all the bridges in an undirected graph by identifying edges that, when removed, increase the number of connected components.
Use Tarjan's algorithm to find bridges in the graph.
Keep track of the discovery time and low time of each vertex during DFS traversal.
An edge (u, v) is a bridge if low[v] > disc[u].
Handle multiple test cases efficiently to find bridges in each graph.
Ensure the output contains the count of bridges and the vertices defining each bridge.
A Linked List in Java is implemented using nodes with references to the next node. It is preferred over an ArrayList when frequent insertions and deletions are required.
In Java, a Linked List is implemented using a Node class with data and a reference to the next Node.
LinkedList class in Java provides methods like add(), remove(), and get() for manipulating the list.
Linked List is preferred over ArrayList when frequent insertions and deletions are needed due to its constant-t...read more
Paytm is a leading Indian digital payment platform offering a wide range of services including mobile recharges, bill payments, and online shopping.
Founded in 2010 by Vijay Shekhar Sharma
Offers services like mobile recharges, bill payments, online shopping, and digital wallet
Acquired by One97 Communications in 2013
Expanded into financial services like Paytm Payments Bank and Paytm Money
One of the largest digital payment platforms in India
A nested SQL query is a query within another query, used to retrieve data from multiple tables in a single query.
Nested queries are enclosed within parentheses and can be used in SELECT, INSERT, UPDATE, or DELETE statements.
They are commonly used to perform subqueries to filter results based on the output of the inner query.
Example: SELECT * FROM table1 WHERE column1 IN (SELECT column2 FROM table2 WHERE condition);

Top Full Stack Developer Interview Questions from Similar Companies







Reviews
Interviews
Salaries
Users/Month

