Josh Technology Group
Avati Consulting Solutions (P) Interview Questions and Answers
Q1. Non-Decreasing Array Problem Statement
Given an integer array ARR
of size N
, determine if it can be transformed into a non-decreasing array by modifying at most one element.
An array is defined as non-decreasin...read more
The solution checks if an integer array can become non-decreasing by modifying at most one element.
Iterate through the array and check if there are more than one decreasing pairs of elements.
If there are more than one decreasing pairs, return false.
If there is only one decreasing pair, check if modifying one of the elements can make the array non-decreasing.
If modifying the element at index i-1 or i can make the array non-decreasing, return true.
Otherwise, return false.
Q2. Find Unique Element in Array
You have been provided an integer array/list ARR
of size N
. Here, N
is equivalent to 2M + 1
where each test case has M
numbers appearing twice and one number appearing exactly once....read more
The task is to find the unique number in an array where all other numbers occur twice.
The array size is given by N = 2M + 1, where M is the number of elements occurring twice.
Loop through the array and use a hashmap to count the occurrences of each number.
Return the number with a count of 1, as it is the unique number.
Q3. Sort Linked List Based on Actual Values
You are given a Singly Linked List of integers that is initially sorted according to the absolute values of its elements. Your task is to sort this Linked List based on t...read more
The task is to sort a singly linked list based on actual values instead of absolute values.
Traverse the linked list and store the values in an array
Sort the array using any sorting algorithm
Create a new linked list using the sorted array
Return the new linked list
Q4. Check If Linked List Is Palindrome
Given a singly linked list of integers, determine if the linked list is a palindrome.
Explanation:
A linked list is considered a palindrome if it reads the same forwards and b...read more
Check if a given singly linked list of integers is a palindrome or not.
Create a function to reverse the linked list.
Use two pointers to find the middle of the linked list.
Compare the first half of the linked list with the reversed second half to determine if it's a palindrome.
Diameter of a Binary Tree Problem Statement
Given a binary tree, return the length of its diameter. The diameter of a binary tree is defined as the length of the longest path between any two nodes in the tree.
The diameter of a binary tree is the length of the longest path between any two end nodes in the tree.
The diameter of a binary tree can be calculated by finding the maximum of the following three values: 1) the diameter of the left subtree, 2) the diameter of the right subtree, and 3) the longest path that passes through the root node.
To find the diameter of a binary tree, we can use a recursive approach. We calculate the height of the left and right subtrees, and then calcul...read more
Q6. Merge K Sorted Arrays Problem Statement
Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.
Input
The f...read more
Merge K sorted arrays into a single sorted array.
Create a min heap to store the first element of each array along with the array index.
Pop the top element from the heap, add it to the result array, and push the next element from the same array back to the heap.
Repeat the process until all elements are processed.
Time complexity: O(N log K) where N is the total number of elements and K is the number of arrays.
Q7. Segregate Odd-Even Problem Statement
In a wedding ceremony at NinjaLand, attendees are blindfolded. People from the bride’s side hold odd numbers, while people from the groom’s side hold even numbers. For the g...read more
Rearrange a linked list such that odd numbers appear before even numbers while preserving the order.
Create two separate linked lists for odd and even numbers
Traverse the original list and append nodes to respective odd/even lists
Combine the odd and even lists while maintaining the order
Return the rearranged linked list
Q8. Remove Duplicates Problem Statement
You are given an array of integers. The task is to remove all duplicate elements and return the array while maintaining the order in which the elements were provided.
Example...read more
Remove duplicates from an array of integers while maintaining order.
Iterate through the array and add elements to a new array if they are not already present
Use a hash set to keep track of unique elements
Return the new array with unique elements in the same order as the original array
Interview Process at Avati Consulting Solutions (P)
Top Front end Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month