Adobe
Sanghi Jewellers Interview Questions and Answers
Q1. Maximum Sum Problem Statement
You are given an array ARR
of N integers. Your task is to perform operations on this array until it becomes empty, and maximize the sum of selected elements. In each operation, sel...read more
The task is to maximize the sum of selected elements from an array by following specific rules.
Select elements strategically to maximize the sum
Remove occurrences of selected element, and its neighbors
Repeat the process until the array becomes empty
Q2. Rearrange The Array Problem Statement
You are given an array/list 'NUM' of integers. Rearrange the elements of 'NUM' such that no two adjacent elements are the same in the rearranged array.
Example:
Input:
NUM[...read more
The task is to rearrange an array such that no two adjacent elements are the same.
Iterate through the array and check if any adjacent elements are the same.
If adjacent elements are the same, swap one of them with a different element.
Return 'YES' if a valid rearrangement is possible, 'NO' otherwise.
Q3. Ways to Reach Nth Stair
Given the number of stairs, initially at the 0th stair, you need to reach the Nth stair. Each time, you can either climb one step or two steps. Determine the number of distinct ways to c...read more
Calculate the number of distinct ways to climb N stairs by either taking one or two steps at a time.
Use dynamic programming to keep track of the number of ways to reach each stair
The number of ways to reach a stair is the sum of the number of ways to reach the previous two stairs
Return the result modulo 10^9+7
Q4. Level Order Traversal of Binary Tree
Given a binary tree of integers, return its level order traversal.
Input:
The first line contains an integer 'T' which represents the number of test cases. For each test cas...read more
Level Order Traversal of Binary Tree returns nodes in level order traversal.
Perform a level order traversal of the binary tree starting from the root node.
Visit nodes level by level, printing them in the order they are encountered.
Use a queue data structure to keep track of nodes at each level.
Q5. Top View of Binary Tree Problem Statement
Given a binary tree, your task is to print the Top View of the Binary Tree. The Top View is the set of nodes visible when the tree is viewed from the top. Please ensure...read more
The task is to print the Top View of a Binary Tree, which is the set of nodes visible when viewed from the top, in left to right order.
Traverse the binary tree in level order and maintain a map to store the horizontal distance of each node from the root.
For each node, if the horizontal distance is not already in the map, add the node's value to the result.
Print the values from the map in ascending order of horizontal distance to get the Top View of the Binary Tree.
Q6. Left View of a Binary Tree Problem Statement
Given a binary tree, your task is to print the left view of the tree.
Example:
Input:
The input will be in level order form, with node values separated by a space. U...read more
The task is to print the left view of a binary tree given in level order form.
Traverse the tree level by level and print the first node of each level (leftmost node).
Use a queue to keep track of nodes at each level.
Consider null nodes as well while traversing the tree.
Design a system to store incoming characters in sorted manner and answer queries about character presence.
Use a data structure like a balanced binary search tree to store characters in sorted order.
Implement functions to insert characters into the tree and check for character presence.
Optimize search queries by using binary search or tree traversal techniques.
Consider edge cases like duplicate characters and handling special characters.
Example: Insert 'a', 'c', 'b' -> Tree: [...read more
More about working at Adobe
Reviews
Interviews
Salaries
Users/Month