PayPal
10+ Jnanada IT Solutions Interview Questions and Answers
Q1. Sum Queries in a Sorted Array
Given two arrays arr
and queries
, your task is to determine the sum of all elements in arr
that are less than or equal to each element in queries
. The array arr
is provided in sort...read more
Find sum of elements in a sorted array less than or equal to each element in queries.
Iterate through queries and for each query, find the sum of elements in arr less than or equal to the query element.
Use binary search to efficiently find the index of the last element less than or equal to the query element.
Keep track of cumulative sum while iterating through arr to avoid recalculating sums.
Return the list of sums for each test case.
Q2. Minimum Character Deletion Problem Statement
You have been provided a string STR
. Your task is to find and return the minimum number of characters that need to be deleted from STR
so that each character's frequ...read more
Find the minimum number of character deletions needed to make each character's frequency unique in a given string.
Iterate through the string and count the frequency of each character.
Identify characters with the same frequency and calculate the minimum deletions needed to make them unique.
Return the total minimum deletions for each test case.
Q3. Count Ways To Reach The N-th Stair Problem Statement
You are given a number of stairs, N
. Starting at the 0th stair, you need to reach the Nth stair. Each time you can either climb one step or two steps. You ha...read more
The problem involves finding the number of distinct ways to climb to the N-th stair by taking one or two steps at a time.
Use dynamic programming to solve this problem efficiently.
The number of ways to reach the N-th stair is the sum of the number of ways to reach the (N-1)th stair and the (N-2)th stair.
Handle large inputs by taking modulo 10^9+7 of the result.
Example: For N=3, there are 3 ways to climb to the third stair: (0, 1, 2, 3), (0, 2, 3), and (0, 1, 3).
Q4. Reverse Only Letters Problem Statement
You are given a string S
. The task is to reverse the letters of the string while keeping non-alphabet characters in their original position.
Example:
Input:
S = "a-bcd"
Ou...read more
Reverse the letters of a string while keeping non-alphabet characters in their original position.
Iterate through the string and store the non-alphabet characters in their original positions.
Reverse the letters of the string using two pointers approach.
Combine the reversed letters with the non-alphabet characters to get the final reversed string.
Q5. Next Greater Element Problem Statement
You are given an array arr
of length N
. For each element in the array, find the next greater element (NGE) that appears to the right. If there is no such greater element, ...read more
The task is to find the next greater element for each element in an array to its right, if no greater element exists, return -1.
Use a stack to keep track of elements for which the next greater element is not found yet.
Iterate through the array from right to left and pop elements from the stack until a greater element is found.
Store the next greater element for each element in a separate array.
If the stack is empty after iterating through the array, it means there is no greate...read more
Q6. Problem: Sort an Array of 0s, 1s, and 2s
Given an array/list ARR
consisting of integers where each element is either 0, 1, or 2, your task is to sort this array in increasing order.
Input:
The input starts with...read more
Sort an array of 0s, 1s, and 2s in increasing order.
Use a three-pointer approach to partition the array into sections of 0s, 1s, and 2s.
Iterate through the array and swap elements based on their values to achieve the sorting.
Time complexity should be O(N) where N is the number of elements in the array.
Q7. Left View of a Binary Tree
Given a binary tree, your task is to print the left view of the tree. The left view of a binary tree contains the nodes visible when the tree is viewed from the left side.
Input:
The ...read more
The task is to print the left view of a binary tree, which contains the nodes visible when the tree is viewed from the left side.
Traverse the tree level by level and keep track of the leftmost node at each level
Use a queue for level order traversal and a map to store the leftmost nodes
Print the values of the leftmost nodes stored in the map as the left view of the tree
Q8. Palindrome Checker Problem Statement
Given an alphabetical string S
, determine whether it is a palindrome or not. A palindrome is a string that reads the same backward as forward.
Input:
The first line of the i...read more
Check if a given string is a palindrome or not.
Iterate through the string from both ends and compare characters.
If all characters match, return 1 indicating a palindrome.
If any characters don't match, return 0 indicating not a palindrome.
Q9. Find The Sum Of The Left Leaves Problem Statement
Given a binary tree with ‘root’, your task is to find and return the sum of all the left leaf nodes.
Example:
Input:
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
Outpu...read more
Find and return the sum of all the left leaf nodes in a binary tree.
Traverse the binary tree using depth-first search (DFS)
Check if a node is a leaf node and a left child
Sum up the values of all left leaf nodes
Q10. Median of Two Sorted Arrays
Given two sorted arrays A
and B
of sizes N
and M
, find the median of the merged array formed by combining arrays A
and B
. If the total number of elements, N + M
, is even, the median ...read more
Find the median of two sorted arrays by merging them and calculating the median of the combined array.
Merge the two sorted arrays into one sorted array.
Calculate the median of the combined array based on the total number of elements.
Return the median as the result.
Q11. Find K Closest Elements
Given a sorted array 'A' of length 'N', and two integers 'K' and 'X', your task is to find 'K' integers from the array closest to 'X'. If two integers are at the same distance, prefer th...read more
Given a sorted array, find K integers closest to X, preferring smaller ones in case of same distance.
Use binary search to find the closest element to X in the array.
Maintain two pointers to expand around the closest element to find K closest elements.
Compare distances and values to select the K closest elements, preferring smaller ones if distances are equal.
Q12. Similar String Groups Problem Statement
Two strings S1
and S2
are considered similar if either S1
equals S2
or we can swap two letters of S1
at different positions so that it equals S2
.
Input:
The first line of...read more
The problem involves determining the number of similar string groups in a given list of strings based on a specific criteria.
Iterate through each pair of strings in the list and check if they are similar based on the given criteria.
Use a hash set to keep track of visited strings to avoid counting duplicates in the same group.
Consider implementing a function to check if two strings are similar by allowing at most one swap of characters.
Count the number of distinct groups of si...read more
Approach to low-level system design involves understanding requirements, breaking down components, defining interfaces, and optimizing performance.
Understand the requirements and constraints of the system
Break down the system into smaller components/modules
Define clear interfaces between components for communication
Optimize performance by considering data structures, algorithms, and resource utilization
I remain calm, assess the situation, prioritize tasks, communicate effectively, and collaborate with team members to find a solution.
Remain calm and composed under pressure
Assess the situation to understand the root cause
Prioritize tasks based on urgency and impact
Communicate effectively with team members and stakeholders
Collaborate with team members to brainstorm and implement solutions
Interview Process at Jnanada IT Solutions
Top SDE-2 Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month