Adobe
300+ Alcon Interview Questions and Answers
Rick gave Morty an array 'Arr' of length ‘N’ and an integer ‘K’ and asked him to find the minimum possible cost to split the array into non-empty sub-arrays such that the following conditions...read more
You have been given a singly Linked List of integers. Your task is to delete the middle node of this List.
Note:
1. If there is no middle node in the list to delete, return an empty list (i.e....read more
The task is to delete the middle node of a singly linked list of integers.
If the linked list is empty or has only one node, there is no middle node to delete.
To delete the middle node, we need to find the middle node and update the pointers of the previous and next nodes.
To find the middle node in one traversal, we can use two pointers - a slow pointer and a fast pointer.
The slow pointer moves one node at a time, while the fast pointer moves two nodes at a time.
When the fast ...read more
You are given an integer array ‘ARR’. You have to find the length of the shortest contiguous subarray such that, if you sort this subarray in ascending order, then the whole array will be sorted in asce...read more
The task is to find the length of the shortest contiguous subarray that needs to be sorted in order to sort the entire array.
Iterate through the array from left to right and find the first element that is out of order.
Iterate through the array from right to left and find the first element that is out of order.
Find the minimum and maximum elements within the subarray defined by the above two elements.
Expand the subarray to include any additional elements that are out of order ...read more
You are given an array consisting of N positive integers, and your task is to sort the array in decreasing order of count of set bits in the binary representation of ...read more
Aahad and Harshit always have fun by solving problems. Harshit took a sorted array and rotated it clockwise by an unknown amount. For example, he took a sorted array = [1, 2, 3, 4,...read more
This is a problem where a sorted array is rotated and we need to search for given numbers in the array.
The array is rotated clockwise by an unknown amount.
We need to perform binary search to find the index of the given numbers.
If the number is found, return its index. Otherwise, return -1.
The time complexity of the solution should be O(logN).
You are given an array of integers. You need to sort the array in ascending order using quick sort.
Quick sort is a divide and conquer algorithm in which we choose a pivot point and partition the arra...read more
The question asks to implement quick sort algorithm to sort an array of integers in ascending order.
Quick sort is a divide and conquer algorithm
Choose a pivot point and partition the array into two parts
Recursively sort the left and right parts of the array
Implement the quick sort algorithm to sort the given array
You are given an integer 'N'. Your task is to find the number formed after swapping each even bit of 'N' in its binary representation with its adjacent bit on the right, assuming that the...read more
The task is to swap each even bit of an integer with its adjacent bit on the right in its binary representation.
Convert the given integer to its binary representation
Iterate through the binary representation and swap each even bit with its adjacent bit on the right
Convert the modified binary representation back to an integer
Print the resulting integer
Ninja has been given a string ‘STR’ containing either ‘{’ or ‘}’. 'STR’ is called valid if all the brackets are balanced. Formally for each opening bracket, there must be a clos...read more
You have to classify a string as “GOOD”, “BAD” or “MIXED”. A string is composed of lowercase alphabets and ‘?’. A ‘?’ is to be replaced by any of the lowercase alphabets. Now you have to classi...read more
Given a singly linked list of integers. Your task is to return the head of the reversed linked list.
For example:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked lis...read more
Write a program to find x to the power n (i.e., x^n). Take x and n from the user. You need to print the answer.
Note: For this question, you can assume that 0 raised to the power of 0 is 1...read more
You are given a binary search tree of integers with N nodes. You are also given references to two nodes P and Q from this BST.
Your task is to find the lowest common ancestor(LCA) of these two given...read more
The task is to find the lowest common ancestor (LCA) of two given nodes in a binary search tree (BST).
The LCA is the lowest node that has both given nodes as descendants.
In a BST, the left subtree of a node contains only nodes with data less than the node's data, and the right subtree contains only nodes with data greater than the node's data.
Start from the root node and compare it with the given nodes. If both nodes are smaller than the current node, move to the left subtree...read more
You are given two sorted linked lists. You have to merge them to produce a combined sorted linked list. You need to return the head of the final linked list.
Note:
The given linked ...read more
The task is to merge two sorted linked lists into a single sorted linked list.
Create a new linked list to store the merged list
Compare the values of the nodes from both lists and add the smaller value to the new list
Move the pointer of the list with the smaller value to the next node
Repeat the comparison and addition until one of the lists is empty
Add the remaining nodes from the non-empty list to the new list
Return the head of the new list
1. There are 100 doors in a row, all doors are initially closed. A person walks through all doors multiple times and toggle (if open then close, if close then open) them in following way: In first walk, ...read more
You are given a N x M matrix of integers, return the spiral path of the matrix
Example Of Spiral Path
Input Format:
The first line contains an integer 'T' which denotes the number of test cases or...read more
The task is to return the spiral path of a given matrix.
Iterate through the matrix in a spiral pattern, starting from the outermost layer and moving towards the center.
Keep track of the current row, column, and the boundaries of the remaining unvisited matrix.
Print the elements in the spiral path as you traverse the matrix.
Implement a SpecialStack Data Structure that supports getMin() in O(1) time and O(1) extra space along with push(), pop(), top(), isEmpty()...read more
You are given an array ‘ARR’ consisting of ‘N’ positive integers. Your task is to find if the number has exactly 3 factors for each number in the array ‘ARR’.
You have to return an array con...read more
Given a binary tree with N number of nodes, check if that input tree is BST (Binary Search Tree) or not. If yes, return true, return false otherwise.
A binary search tree (BST) is a binary tree data...read more
You are given an array/list of ‘N’ integers. You are supposed to return the maximum sum of the subsequence with the constraint that no two elements are adjacent in the given ...read more
You are given 'N' stones labeled from 1 to 'N'. The 'i-th' stone has the weight W[i]. There are 'M' colors labeled by integers from 1 to 'M'. The 'i-th' stone has the color C[i] which ...read more
Ninja loves playing with numbers. So his friend gives him an array on his birthday. The array consists of positive and negative integers. Now Ninja is interested in finding the length of ...read more
Given a string 'S', you are supposed to return the number of distinct substrings(including empty substring) of the given string. You should implement the program using a trie.
Note :
A ...read more
Given a string ‘str’. Find the minimum number of partitions to make in the string such that every partition of the string is a palindrome.
Given a string, make cuts in that string to mak...read more
You are given a binary tree having 'N' nodes. Each node of the tree has an integer value. Your task is to find the maximum possible sum of a simple path between any two nodes (p...read more
You are given an array Arr consisting of N integers. You need to find the equilibrium index of the array.
An index is considered as an equilibrium index if the sum of elements of the array to t...read more
There is a one-dimensional garden of length 'N'. On each of the positions from 0 to 'N', there is a fountain, and this fountain’s water can reach up to a certain range as explained further. In ...read more
You are given the schedule of N meetings with their start time Start[i] and end time End[i]. But you have only 1 meeting room. So, you need to tell the meeting numbers you can organize in the gi...read more
You have given an integer array ‘arr’ size ‘N’. You have to split the array into ‘K’ consecutive non-overlapping subarrays of length ‘M’ such that...read more
You are given an array 'ARR' of positive integers, each of which represents the number of liters of water in that particular bucket, we have to make the liters of water in every bucket equal.
We are allow...read more
You are given a starting position for a rat which is stuck in a maze at an initial point (0, 0) (the maze can be thought of as a 2-dimensional plane). The maze would be given in the form of a squar...read more
You are given a list of ‘transactions’ between ‘n’ number of friends. who have to give each other money. The list consists of data of receiver, sender, and transaction.
Your task is to minimiz...read more
You are given an array “ARR” of N integers. You are required to perform an operation on the array each time until it becomes empty. The operation is to select an element from the array(let’s say at i...read more
Given a text and a wildcard pattern of size N and M respectively, implement a wildcard pattern matching algorithm that finds if the wildcard pattern is matched with the text. The matchi...read more
You are given a string 'S' containing dots(.) and asterisks(*) only, where the dot represents free spaces, and the asterisk denotes lamps. A lamp can lighten up its...read more
You are given an array 'ARR' of distinct positive integers. You need to find all numbers that are in the range of the elements of the array, but not in the array. The missing elements should be p...read more
You are given two arrays 'A' and 'B' of size 'N' and 'M' respectively. Both these arrays are sorted in non-decreasing order. You have to find the intersection of these two arrays.
Inte...read more
You have been given an array/list ‘ARR’ consisting of ‘N’ positive integers. Your task is to return the Next Greater Element(NGE) for every element.
The Next Greater Element for an element ‘...read more
You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two steps. You are...read more
You are given an N * N matrix of integers where each row and each column is sorted in increasing order. You are given a target integer 'X'. Find the position of...read more
You are given an array/list ‘arr’ of size ‘n’. Your task is to find the maximum product possible by taking any subset of the array/list ‘arr’.
Since the product can be large, return it modulo ...read more
You have given an integer array/list ‘arr’ of size ‘N’. You have to split the array into the maximum number of subarrays such that the first and last occurrence of every distin...read more
Given a singly linked list, you have to detect the loop and remove the loop from the linked list, if present. You have to make changes in the given linked list itself and return the update...read more
Q44. You have a lot of small integers in an array. You have to multiply all of them. You need not worry about overflow and range, you have enough support for that. What can you do to speed up the multiplication on y...
read moreTo speed up multiplication of small integers in an array, we can use bitwise operations and parallel processing.
Use bitwise operations like shifting and ANDing to perform multiplication faster.
Divide the array into smaller chunks and perform multiplication in parallel using multi-threading or SIMD instructions.
Use lookup tables for frequently used values to avoid repeated calculations.
Use compiler optimizations like loop unrolling and vectorization.
Consider using specialized ...read more
You have given an integer array/list ‘arr’ of size ‘N’. You have to split the array into the maximum number of subarrays such that the first and last occurrence of every distinct element lies in a si...read more
You live in a Ninja town which is in the form of a N * M grid. In this town, people travel from one place to another by jumping over the buildings which are present in each cell of the grid. It is Chri...read more
Implement a Stack Data Structure specifically to store integer data using two Queues.
There should be two data members, both being Queues to store the data internally. You may use the inbuilt Q...read more
Kevin has two packs of cards. The first pack has N cards and the second one has M cards. Every card has an integer written on it. Now, you have to tell two things. First, how many different t...read more
You have been given a complete binary tree of ‘N’ nodes. The nodes are numbered 1 to ‘N’.
You need to find the ‘next’ node that is immediately right in the level order...read more
You are given an array ‘A’ of length ‘N’, you have to choose an element from any index in this array and delete it. After deleting the element you will get a new array of length ‘N’-1. Your task is t...read more
You have been given a board where there are '2' rows and 'N' columns. You have an infinite supply of 2x1 tiles, and you can place a tile in the following ways:
1. Horizontally as 1x2 tile 2. Verti...read more
Given a sequence of numbers. Find all leaders in sequence. An element is a leader if it is strictly greater than all the elements on its right side.
Note:
1. Rightmost element is always a le...read more
You’re given three integers X, C, and Y, where X denotes the first term of an arithmetic sequence whose common difference is C. Your task is to determine whether Y belongs to this arithmetic sequenc...read more
You are given a 'N' * 'N' maze with a rat placed at 'MAZE[0][0]'. Find and print all paths that rat can follow to reach its destination i.e. 'MAZE['N' - 1]['N' - 1]'. Rat can move in any ...read more
You have been given an Encrypted String where repetitions of substrings are represented as substring followed by the count of substrings.
Example: String "aabbbcdcdcd" wil...read more
Given an array/list of integer numbers 'CHOCOLATES' of size 'N', where each value of the array/list represents the number of chocolates in the packet. There are ‘M’ number of students and the t...read more
You have been given an array/list 'ARR' of integers. Your task is to find the second largest element present in the 'ARR'.
Note:
a) Duplicate elements may be present. b) If no...read more
You have given a Singly Linked List of integers, determine if it forms a cycle or not.
A cycle occurs when a node's next points back to a previous node in the list. The linked list is no l...read more
Pre-requisites: Anagrams are defined as words or names that can be formed by rearranging letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "r...read more
You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two steps. You are supposed to...read more
Given a binary tree. Print the Top View of Binary Tree. Print the nodes from left to right order.
Example:
Input:
Output: 2 35 2 10 2
Input format :
The first line contains an Integer ...read more
Ninja is given an array of integers that contain numbers in random order. He needs to write a program to find and return the number which occurs the maximum times in the given input. He ...read more
You have been given a binary search tree of integers with ‘N’ nodes. You are also given 'KEY' which represents data of a node of this tree. Your task is to find the predecessor a...read more
You are given an integer ‘K’, and two numbers ‘A’ and ‘B’. You need to count the occurrences of the given digit ‘K’, in the range [A, B].
Note:
You need to count occurrences at every place ...read more
Implement a queue data structure which follows FIFO(First In First Out) property, using only the instances of the stack data structure.
Note:
1. To implement means you need to complete some pr...read more
Given a binary tree. Print the Left View of the Tree.
Example :
If the input tree is as depicted in the picture:
The Left View of the tree will be: 2 35 2
Input format :
Elements in t...read more
You have been given a sorted array/list ARR consisting of ‘N’ elements. You are also given an integer ‘K’.
Now the array is rotated at some pivot point unknown to you. For example,...read more
You are given ‘N’ items with certain ‘PROFIT’ and ‘WEIGHT’ and a knapsack with weight capacity ‘W’. You need to fill the knapsack with the items in such a way that you get the maximum profit. ...read more
Q69. There are N cities spread in the form of circle. There is road connectivity b/w city 1 and 2, then city 2 and 3 and so on till city n and 1. Each ith city has a petrol pump where you can pick pith petrol and di...
read moreGiven a binary tree, return the zigzag level order traversal of the nodes' values of the given tree. Zigzag traversal means starting from left to right, then right to left for the ne...read more
You are given a 2-D array 'MATRIX' of dimensions N x M, of integers. You need to return the spiral path of the matrix.
Example Of Spiral Path:
Input Format:
The first line contains an integer 'T' ...read more
You have been given a Binary Tree of integers. You are supposed to return the level order traversal of the given tree.
For example:
For the given binary tree
The level orde...read more
Given a binary tree of integers, you need to print the binary tree in a 2-D array of string such that -
1. There should be ‘H’ number of rows in the matrix where ‘H’ is the binary tree’s height...read more
100 prisoners in jail are standing in a queue facing in one direction. Each prisoner is wearing a hat of color either black or red. A prisoner can see hats of all prisoners in front of him in the queue, b...read more
There are 4 persons (A, B, C and D) who want to cross a bridge in night.
A takes 1 minute to cross the bridge.
B takes 2 minutes to cross the bridge.
C takes 5 minutes to cross the bridge.
D takes 8 minutes t...read more
Given a binary tree, convert this binary tree into its mirror tree.
A binary tree is a tree in which each parent node has at most two children.
Mirror of a Tree: Mirror...read more
Q77. Given a program: int i; int main() { int j; int *k = (int *) malloc (sizeof(int)); … } Where are each of these variables stored?
i is stored in global data segment, j is stored in stack, k is stored in heap.
i is a global variable and is stored in the global data segment
j is a local variable and is stored in the stack
k is a pointer variable and is stored in the stack, while the memory it points to is allocated on the heap using malloc()
She then Asked me Various Mutex related puzzles like “IF you have adobe acrobat and you want to allow only 1 instance of it to run at a time, how will you achieve this wrt to OS involved.”
I answere...read more
Ninja got a very long summer vacation. Being very bored and tired about it, he indulges himself in solving some puzzles.
He encountered a problem in which he was given two arrays...read more
You are given an array/list 'NUM' of integers. You are supposed to rearrange the elements of the given 'NUM' so that after rearranging the given array/list there are no two adjacent elements ...read more
You have two ropes coated in oil to help them burn. Each rope will take exactly 1 hour to burn all the way through. However, the ropes do not burn at constant rates—there are spots where they burn a littl...read more
You are given a binary tree, where the data present in each node is an integer. You have to find whether the given tree is symmetric or not.
Symmetric tree is a binary tree, whose mirror image ...read more
Q83. Write a client server simple code. How will you handle multiple requests? Will increasing number of threads solve the problem. What should be the optimal number of threads depending upon your computer architect...
read moreClient-server code with optimal thread handling for multiple requests
Use a thread pool to handle multiple requests efficiently
Optimal number of threads depends on CPU cores and available memory
Increasing threads beyond optimal number can lead to resource contention and performance degradation
Q84. Suppose there is an unsorted array. What will be the maximum window size, such that when u sort that window size, the whole array becomes sorted. Eg, 1 2 6 5 4 3 7 . Ans: 4 (6 5 4 3)
Find the maximum window size to sort an unsorted array.
Identify the longest decreasing subarray from the beginning and longest increasing subarray from the end
Find the minimum and maximum element in the identified subarrays
Expand the identified subarrays until all elements in the array are covered
The length of the expanded subarray is the maximum window size
Q85. Puzzle : There is a pond in which there is x kg ice on 1st November, it becomes 2x on 2nd November then 4x,8x,16x,32x and so on.Like this whole pond is filled with ice on last day i.e. 30th November. On which d...
read morePuzzle: On which day in November was the pond filled with half the ice?
The amount of ice in the pond doubles each day in November
The pond is filled with ice on the last day of November
To find the day when the pond was half-filled, work backwards from the last day
What is Diamond Problem in C++ and how do we fix it?
The Diamond Problem is a conflict that occurs when a class inherits from two classes that have a common base class.
The Diamond Problem arises in multiple inheritance.
It occurs when a class inherits from two classes that have a common base class.
This leads to ambiguity in accessing the common base class members.
To fix the Diamond Problem, virtual inheritance is used.
Virtual inheritance ensures that only one instance of the common base class is inherited.
Q87. 33) You are given two hour glasses(those glasses are filled with sand). One hour glass gets emptied by 4 minutes another by 7 minutes. Find how will you calculate 9 minutes. Same puzzle was asked to me in GoldM...
read moreUsing two hour glasses, one emptied in 4 minutes and another in 7 minutes, calculate 9 minutes.
Start both hour glasses simultaneously
When the 4-minute hour glass is empty, flip it again
When the 7-minute hour glass is empty, 4 minutes have passed
Flip the 7-minute hour glass again and wait for it to empty
When it's empty, 9 minutes have passed
You are given a binary tree in which each node contains an integer value and a number ‘K’. Your task is to print every path of the binary tree with the sum of nodes in the path as ‘K’...read more
You are given an array/list consisting of 0 and 1 only. Your task is to find the sum of the number of subarrays that contains only 1 and the number of subarrays that contains only 0.
An array 'C'...read more
There are 3 jars, namely, A, B, C. All of them are mislabeled. Following are the labels of each of the jars:
- A: Candies
- B: Sweets
- C: Candies and Sweets (mixed in a random proportion)
You can put your hand in ...read more
Q91. How do you implement naming of threads from the point of view of a multi-threaded OS.Implement rand5 using rand7.Implement functions to render circles and other figures. (This was mainly about my development at...
read moreImplementing naming of threads in a multi-threaded OS and implementing rand5 using rand7
Use thread ID or thread name to name threads in a multi-threaded OS
Implement a function that generates a random number between 1 and 7
Use rejection sampling to implement rand5 using rand7
Ensure thread names are unique to avoid confusion
Test the implementation thoroughly to ensure correctness
What are Virtual Destructors in C++?
Virtual destructors in C++ are used to ensure that the correct destructor is called when deleting an object through a pointer to its base class.
Virtual destructors are declared in the base class and are used when deleting an object through a pointer to the base class.
They allow proper destruction of derived class objects.
Without virtual destructors, only the base class destructor would be called, leading to memory leaks and undefined behavior.
Virtual destructors are necessary...read more
There is an online catalog of songs (Like Saavn or Gaana). How you will show favorite songs every day to users. An efficient algorithm required. (K max solution/ Min heap solution)
Q94. Given a set of words one after another, give me a data structure so that you’ll know whether a word has appeared already or not
Use a hash table to store the words and check for existence in constant time.
Create a hash table with the words as keys and a boolean value as the value.
For each new word, check if it exists in the hash table. If it does, it has appeared before. If not, add it to the hash table.
Alternatively, use a set data structure to store only the unique words and check for existence in the set.
You are standing before two doors. One of the path leads to heaven and the other one leads
to hell. There are two guardians, one by each door. You know one of them always tells the truth
and the other alway...read more
Q96. 26) There are m machines. each machine generates coins of 10 g.only one machine is defective which generates coins of 9 g.how to find that defective machine in one weighing only. Now there are two defective mac...
read moreQ97. How much memory is made available to a user program by the kernel, is there any limit to it? What is the range of addresses a user program can have at max, what determines it?What happens if excess memory is al...
read moreYou have a birthday cake and have to cut it into 8 equal pieces by making 3 cuts only. How
do you do it?
Q99. 1>linked list node contain a string field and next.find if by concatenating all string fields the string formed is palindrome or not? 2-> merge to sorted array in which one arra is large enough to accomodate el...
read moreThe first question is about checking if a string formed by concatenating all string fields in a linked list is a palindrome or not.
Traverse the linked list and concatenate all string fields
Check if the concatenated string is a palindrome by comparing characters from both ends
Consider edge cases like empty linked list or single node with an empty string field
What are the different types of semaphores ?
Semaphores are synchronization primitives used in operating systems to control access to shared resources.
Binary semaphore: Can take only two values, 0 and 1. Used for mutual exclusion.
Counting semaphore: Can take any non-negative integer value. Used for resource allocation.
Mutex semaphore: A binary semaphore used for mutual exclusion.
Named semaphore: A semaphore that can be accessed by multiple processes.
Unnamed semaphore: A semaphore that can only be accessed by threads wit...read more
More about working at Adobe
Top HR Questions asked in Alcon
Interview Process at Alcon
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month