Adobe
100+ YDTS India Interview Questions and Answers
Q1. 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 moreQ2. 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
Q3. 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
Q4. 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 moreQ5. 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 moreQ6. There is a paragraph having million characters. You have to find out the first non –repeating character in the complete paragraph. For example:- aab cld jb then answer should be :- c
Q7. Write a function which returns 1 when 2 is passed and return 2 when 1 is passed.1 number is missing from an array(1 to n). find thatHe just wanted sum of n terms minus sum of array solution.Now correlate the ab...
read moreQ8. U have n vending machine out of which 1 is defected find the defected machine in O(1) on solving this he modified it give general solution for the case in which 2 machine are defected O(1) solution were require...
read moreTo find 2 defective vending machines out of n machines in O(1) time, label each machine with a unique number and use XOR operation.
Label each machine with a unique number from 1 to n
Calculate the XOR of all the numbers from 1 to n and the XOR of all the numbers of the working machines
The result of XORing these two values will give the XOR of the two defective machines
Find the rightmost set bit in the XOR result, divide the machines into two groups based on that bit, and XOR t...read more
Q9. You are given a string in which every character is followed by space u have to return n/2 string that is each character as a separate string ..extra space were not allowed
Given a string with characters separated by spaces, return each character as a separate string without using extra space.
Split the string by spaces to get an array of characters
Return the array of characters as individual strings
Q10. What is the difference between mutex and a semaphore. Write down a crude implementation of both. How would you solve the mutual exclusion problem using semaphore. Propose a solution to the readers-writer proble...
read moreQ11. Consider a recursive function with no end condition and architecture of your own laptop. What will happen? After how much time will the program crash.(Calculations and perfect answer was required)
Q12. Implement the qsort() in c/sort() in c++ library or your own custom sort which will sort any type of data on user defined criteria. write the function prototype, definition and another requirements
Implementing qsort() or custom sort() function in C/C++ to sort any type of data based on user-defined criteria.
Use qsort() function in C or sort() function in C++ to sort the data.
For custom sorting, define a comparison function that takes two elements and returns a negative, zero, or positive value based on their order.
The comparison function should be passed as a parameter to qsort() or sort() function.
Ensure the comparison function handles different data types and user-de...read more
Q13. There are chocolates each worth x. You have total amount y with you. And you can exchange z wrappers for 1 chocolate. So in this way how many chocolates he can eat
Q14. given a set of points in a plane, how would you make the most optimized triangular mesh-each point is a vertex of a triangle
To make the most optimized triangular mesh, use a Delaunay triangulation algorithm.
Use a Delaunay triangulation algorithm to connect the points with triangles.
Delaunay triangulation ensures that no point is inside the circumcircle of any triangle.
This algorithm creates triangles with the minimum angle possible, resulting in an optimized mesh.
Popular algorithms for Delaunay triangulation include Bowyer-Watson and incremental algorithms.
Q15. What is the running time for insertion, deletion and searching an element in a sorted array and the same for an unsorted array?
The running time for insertion, deletion, and searching in a sorted array is O(log n), while in an unsorted array it is O(n).
In a sorted array, insertion, deletion, and searching can be done using binary search, which has a time complexity of O(log n).
In an unsorted array, insertion and deletion require shifting elements, resulting in a time complexity of O(n). Searching also requires checking each element, resulting in a time complexity of O(n).
Q16. How would you determine if a coin is biased or not. Does the degree of biasity effect the number of experiments you have to perform?
Q17. In array only 1 element is unique rest are 2 times. How to find that? He further extend if one unique and rest are multiple of 3
Q18. Many typical C/C++ declaration, memory allocation difference between new/malloc, free/delete and details about how memory allocation takes place
C/C++ memory allocation differences between new/malloc, free/delete, and details on how memory allocation takes place.
C/C++ use new/delete for objects and malloc/free for raw memory allocation
new calls constructor, malloc does not
delete calls destructor, free does not
new throws exception on failure, malloc returns NULL
Memory allocation involves finding a contiguous block of memory and marking it as allocated
Q19. Suppose there are packages having volume m and there are n packets having volume a,b,c…. each having volume less than m. So you need to find out the minimum no. of packets required to wrap up the products
Q20. Complete code.There are balls of red, blue and green color. How will you sort them.Implement a generic swap function
Q21. There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration (comparision). All the nuts/bolts might have different diameter
Use quicksort algorithm to match nuts and bolts in minimum iterations.
Use quicksort algorithm to sort both nuts and bolts arrays based on diameter.
Compare each nut with each bolt to find matching pairs.
Time complexity is O(nlogn) using quicksort.
Q22. Explain multithreading and how global, static etc variables are stored and accessed by threads
Multithreading allows multiple threads to run concurrently. Global and static variables are stored in a shared memory space and accessed by all threads.
Multithreading enables concurrent execution of multiple threads.
Global and static variables are stored in a shared memory space accessible by all threads.
Threads can read and modify the values of global and static variables.
Synchronization mechanisms like locks or semaphores are used to prevent data races and ensure thread saf...read more
Q23. If F() generates 0 or 1 with probability .5 each, generate 0-7 with equal probability
To generate 0-7 with equal probability, use F() twice to generate a binary number and convert it to decimal.
Call F() twice to generate two binary digits
Combine the two binary digits to form a binary number
Convert the binary number to decimal to get a number between 0-3
Multiply the decimal number by 2 to get a number between 0-6
Add 1 to the result to get a number between 1-7
Q24. Two strings were given. You have to find whether they are permutations of each other. I gave the hashing technique. He then asked me to optimize it
Q25. Two string are given check whether second string are substring of 1st string or not second string may contain wild card character like ‘*’ and ‘?’
Check if second string is a substring of the first string with wildcard characters.
Use a sliding window approach to compare characters of both strings.
Handle wildcard characters '*' and '?' appropriately.
Consider all possible combinations of wildcard characters in the second string.
Q26. U have given a link list make a new link list which is reverse of original link list
Reverse a given linked list to create a new linked list.
Traverse the original linked list and store each node in a stack
Pop elements from the stack to create a new linked list in reverse order
Q27. Why so many sorting algorithms present where only one can serve the purpose
Q28. Where are local variables, dynamic allocated variables, global variables stored?
Local variables are stored on the stack, dynamic allocated variables are stored on the heap, and global variables are stored in the data segment.
Local variables are stored on the stack and are only accessible within the scope of the function where they are declared.
Dynamic allocated variables are stored on the heap and can be accessed globally by different parts of the program.
Global variables are stored in the data segment and can be accessed from any part of the program.
Q29. What happens when a C program is compiled and executed in details
Q30. Difference between process and thread. Give me a real life example where thread can be used
Q31. Real life example where hashmap can be used. Real life example where array can be used
HashMap can be used to store patient information in a hospital. Array can be used to store a list of medications.
HashMap: Store patient ID as key and patient information as value
Array: Store list of medications prescribed to a patient
Q32. Find the number of occurrences of a key in a sorted array. Handle the base case. Write some test cases for it
Q33. sort an array such that all elements at even indices are smaller than their neighbouring odd indexed elements, and all odd indexed elements are greater than their even indexed neighbours
Sort array with even indices smaller than odd and odd indices greater than even.
Loop through array and swap elements if necessary
Use a temporary variable to swap elements
Compare current element with its even/odd indexed neighbour
Q34. Tell about different sorting algorithms and their complexities.
Q35. Suggest method to multiply two object(operator overloading , proper code for overloading was required)
Operator overloading can be used to multiply two objects by defining a custom operator function.
Define a member function for the class that overloads the * operator
Inside the function, perform the multiplication operation on the object's data members
Return the result of the multiplication operation
Q36. What is the running time for insertion, deletion, extracting min from a minHeap
Q37. 1)Given some numbers like 20,10,5,7,30. Make AVL tree and BST of this. The example involved rotations also
Create AVL tree and BST from given numbers with rotations.
Start by creating a binary search tree (BST) with the given numbers.
Then, balance the BST by performing rotations to create an AVL tree.
AVL tree rotations include left-left, right-right, left-right, and right-left rotations.
Ensure that the AVL tree maintains the balance factor of each node.
The final AVL tree should have the numbers 5, 7, 10, 20, and 30 in the correct order.
Q38. 30)Write a c program to select a contiguous subarray of size m from an array such that its sum is closest to zero
This C program selects a contiguous subarray of size m from an array with the sum closest to zero.
Iterate through the array and calculate the sum of each subarray of size m
Keep track of the subarray with the closest sum to zero
Return the subarray with the closest sum to zero
Q39. 22) Longest common substring between two strings. Two solutions by dynamic programming and by trie were given by me
The longest common substring between two strings can be found using dynamic programming or trie.
Dynamic programming approach involves creating a matrix to store the lengths of common substrings at each position.
Trie approach involves inserting all substrings of one string into a trie and then finding the longest common prefix with the other string.
Examples: For strings 'ABCD' and 'BCDE', the longest common substring is 'BC'. For strings 'ABC' and 'DEF', there is no common sub...read more
Q40. Write a program to search an element in a row-wise and column-wise sorted 2-dimesional array .
Program to search an element in a sorted 2D array
Start from the top-right corner of the array
Compare the target element with the current element
If the target is smaller, move left; if larger, move down
Repeat until the target is found or the boundaries are crossed
Q41. 8) A C output on expansion of Macro. That expansion was to be done very carefully ,otherwise you may get wrong answer
The question asks about the output of expanding a macro in C, emphasizing the need for careful expansion to avoid incorrect results.
Macro expansion in C involves replacing the macro with its corresponding code before compilation.
If the expansion is not done carefully, it can lead to unexpected or incorrect results.
Careful expansion includes considering operator precedence, parentheses, and proper substitution.
Example: Given a macro #define SQUARE(x) x * x, expanding SQUARE(2+...read more
Q42. Write a program to convert a binary tree to binary search tree
A program to convert a binary tree to binary search tree.
Perform an inorder traversal of the binary tree to get the sorted elements.
Create a new binary search tree and insert the sorted elements in the correct order.
The resulting binary search tree will have the same elements as the original binary tree, but in sorted order.
Q43. Write a function to find 2nd largest element in an array
A function to find the second largest element in an array.
Sort the array in descending order
Return the element at index 1
Q44. Which data structure you will use.
It depends on the specific use case and requirements.
Consider the type of data being stored and the operations that need to be performed on it.
Common data structures include arrays, linked lists, stacks, queues, trees, and graphs.
For example, if the data needs to be accessed randomly and quickly, an array may be the best choice.
If the data needs to be sorted or searched frequently, a tree or hash table may be more appropriate.
Ultimately, the choice of data structure will depe...read more
Q45. Any base to any base conversion i.e base 11 to base 7
Converting a number from base 11 to base 7 involves dividing the number by 7 and keeping track of remainders.
Divide the number in base 11 by 7 and keep track of remainders
Repeat the process with the quotient until it becomes 0
The remainders obtained in reverse order will give the number in base 7
Q46. Write complete code for the number of ways a frog can reach nth step by jumping 1 or 2 steps
Q47. Intersection of two lines in a plane, if they intersect- determine the point of intersection
Intersection of two lines in a plane can be determined by solving the equations of the lines simultaneously.
To find the point of intersection, set the equations of the two lines equal to each other and solve for the variables.
If the lines are in slope-intercept form (y = mx + b), set the two equations equal to each other and solve for x and y.
If the lines are in standard form (Ax + By = C), solve the system of equations to find the point of intersection.
Q48. Write code for inverted index for MapReduce. Mapper and Reducer Functions
Q49. why are you increasing fast pointer by 2 only
Q50. How google handles 1 billion request in 1msec
Q51. Replace a string with another string in a paragraph
This function replaces a specified string with another string in a given paragraph.
Use the replace() method to replace the string.
Pass the original string, the string to be replaced, and the replacement string as arguments to the replace() method.
The replace() method returns a new string with the replacements made.
Q52. 35)Size of structure. Small c outputs on union , enums etc
The size of a structure in C depends on the size of its members, including unions and enums.
The size of a structure is determined by the sum of the sizes of its members.
Unions share the same memory space, so the size of a union is equal to the size of its largest member.
Enums are typically represented as integers, so their size depends on the size of an integer in the system.
Q53. Advantages and disadvantages of quick sort and merge sort
Quick sort is faster on average but merge sort is more stable and guarantees O(n log n) time complexity.
Quick sort has an average time complexity of O(n log n) and is in-place, but worst-case time complexity of O(n^2).
Merge sort has a stable time complexity of O(n log n) but requires extra space for merging.
Quick sort is not stable, while merge sort is stable.
Quick sort is often preferred for arrays with a large number of elements, while merge sort is preferred for linked lis...read more
Q54. Explain virtual memory and how mapping is done
Q55. given two nodes of a binary tree, find their first common ancestor
Find the first common ancestor of two nodes in a binary tree.
Traverse the tree from the root node and check if both nodes are in the left or right subtree of the current node.
If they are in different subtrees, then the current node is the first common ancestor.
If they are in the same subtree, continue traversing that subtree until they are in different subtrees.
If one of the nodes is the ancestor of the other, return the ancestor node.
If one of the nodes is not in the tree, r...read more
Q56. given a directory, list all unique filenames inside that directory, in minimum time
To list all unique filenames in a directory in minimum time.
Use a hash set to store unique filenames
Iterate through each file in the directory
Check if the filename is already in the hash set, if not, add it
Return the hash set as an array of strings
Q57. Optimize a program to find duplicate no in array of n numbrs
Q58. What happened in Microsoft last round?
Q59. What is virtual memory and thrashing
Virtual memory is a memory management technique that allows the computer to use secondary storage as an extension of RAM.
Virtual memory is a combination of RAM and disk space.
It allows the computer to run more programs than it has physical RAM for.
When a program needs more memory than is available in RAM, the operating system moves some data from RAM to disk, freeing up space for other programs.
This swapping of data between RAM and disk is known as paging.
Thrashing occurs whe...read more
Q60. Find least common ancestor in BST and then in binary tree
The least common ancestor (LCA) is the lowest node that has both given nodes as descendants.
For a binary search tree (BST), the LCA can be found by comparing the values of the nodes with the given nodes.
For a binary tree, the LCA can be found by recursively searching for the nodes in the left and right subtrees.
If one of the given nodes is the ancestor of the other, it is considered as the LCA.
Q61. Loop in a list and how to find out
Q62. 3)Reversing a singly linked list and double linked list
Reversing a singly linked list involves changing the direction of pointers, while reversing a doubly linked list involves swapping the previous and next pointers.
For singly linked list: iterate through the list and change the direction of pointers to reverse the list.
For doubly linked list: swap the previous and next pointers of each node to reverse the list.
Example for singly linked list: 1 -> 2 -> 3 -> 4 -> null, after reversing: 4 -> 3 -> 2 -> 1 -> null
Example for doubly l...read more
Q63. 27) Producer Consumer semaphore code using semwait and semsignal
Producer Consumer semaphore code using semwait and semsignal
Use semaphores to control access to shared buffer between producer and consumer
Producer signals when it adds an item to the buffer using semsignal
Consumer waits for signal from producer before consuming item using semwait
Q64. Copy a stack into another stack without using an intermediate stack or array
Q65. 3Sum (no. of triplets whose sum is <= target)
Find number of triplets in array whose sum is less than or equal to target.
Sort the array in ascending order.
Use three pointers to iterate through the array and find triplets.
Update pointers based on sum of triplets and target value.
Q66. Where are static variables stored?
Q67. Implement a contiguous 2-d matrix dynamically in C
To implement a contiguous 2-d matrix dynamically in C, you can use a single-dimensional array and calculate the index based on row and column.
Allocate memory for the matrix using malloc or calloc
Access elements using a formula: index = (row * numColumns) + column
Free the memory after use to avoid memory leaks
Q68. Complete code and he ran it for a 4×4 matrix
The interviewee was asked to complete code for a 4x4 matrix and run it.
Ensure the code initializes a 4x4 matrix
Check for any syntax errors or logical mistakes
Run the code to verify the output
Q69. CM of some states and latest android version
The question is about the Chief Ministers of some states and the latest Android version.
The Chief Minister of Maharashtra is Uddhav Thackeray.
The Chief Minister of Tamil Nadu is M.K. Stalin.
The latest Android version is Android 12.
Q70. Declare a 2D array using pointer notation
Q71. Write a Recursive function to reverse a link list
Q72. 25) Merge two sorted linked list without using extra memory
Q73. Implement a push pop operations in a stack
Q74. Write a pseudo code for Singleton Pattern
Q75. 29) Allocate two dimensional matrix using new
Allocate a two-dimensional matrix using the 'new' keyword.
Use the 'new' keyword to dynamically allocate memory for the matrix.
Specify the number of rows and columns in the matrix.
Access elements using the row and column indices.
Remember to deallocate the memory using 'delete' when done.
Q76. Random Pointer in Linked list. Clone it
Cloning a linked list with random pointers.
Create a copy of each node and insert it next to the original node.
Update the random pointers of the copied nodes to point to the corresponding copied nodes.
Separate the original and copied nodes to get the cloned linked list.
Q77. 7) Maximum of three numbers using ternary operator
Using ternary operator to find the maximum of three numbers
Use ternary operator to compare the first two numbers, then compare the result with the third number
Example: int max = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
Q78. 31)Second largest element in a given array
Find the second largest element in a given array of strings.
Sort the array in descending order.
Access the element at index 1 to get the second largest element.
Handle cases where there may be duplicates or less than 2 elements in the array.
Q79. What is Load Balancer?
Q80. Spiral order traversal of a matrix.
Spiral order traversal of a matrix is a way to visit all elements in a matrix in a spiral pattern.
Start by traversing the outermost layer of the matrix from left to right, top to bottom, right to left, and bottom to top.
Continue this pattern for each inner layer until all elements are visited.
Keep track of the boundaries of the matrix to know when to stop.
Q81. Why inheritance is used.
Q82. 2)Lowest common ancestor of a BST
The lowest common ancestor of a Binary Search Tree (BST) is the node that is the closest common ancestor of two given nodes.
Traverse the BST starting from the root node
Compare the values of the two given nodes with the current node's value
If both nodes are on the same side of the current node, move to that side
If the nodes are on different sides, the current node is the lowest common ancestor
Q83. 9)Middle of linked list in one traversal
To find the middle of a linked list in one traversal, use two pointers - one moving at double the speed of the other.
Use two pointers - slow and fast, with fast moving twice as fast as slow
When fast reaches the end, slow will be at the middle of the linked list
Q84. 10) evaluation of a prefix expression
Evaluation of a prefix expression involves evaluating operators before operands.
Start from the rightmost element and move towards the left.
When encountering an operator, apply it to the next two elements in the expression.
Repeat until the entire expression is evaluated.
Example: + * 2 3 4 would be evaluated as (2 * 3) + 4 = 10.
Q85. 32) Implement queue using two stacks
Implement a queue using two stacks
Use two stacks to simulate the behavior of a queue
One stack for enqueue operation and another for dequeue operation
When dequeue is called, check if the second stack is empty, if so, transfer elements from the first stack
Q86. Calculate Fibonacci for nth term
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones.
The Fibonacci sequence starts with 0 and 1.
Each subsequent number is the sum of the two preceding numbers.
The formula to calculate the nth term of the Fibonacci sequence is F(n) = F(n-1) + F(n-2).
For example, the 6th term of the Fibonacci sequence is 8, as 0 + 1 + 1 + 2 + 3 + 5 = 8.
Q87. Reverse a paragraph word-wise
Q88. 13)Pointers to functions
Pointers to functions are used to store the address of functions in C programming.
Pointers to functions are declared using the function's return type and parameters.
They can be used to call functions indirectly.
Example: int (*ptr)(int, int);
Example: ptr = &add; ptr(10, 20);
Q89. Reverse a string efficiently
Q90. Implement a queue using stacks
Implement a queue using stacks
Use two stacks to simulate the behavior of a queue
One stack is used for enqueue operation and the other for dequeue operation
When enqueueing, push elements into the enqueue stack
When dequeuing, if the dequeue stack is empty, transfer elements from enqueue stack to dequeue stack
Return the top element of the dequeue stack for dequeue operation
Q91. Code for Directory Structure
Code for creating a directory structure in a programming language
Use mkdir() function in C to create directories
Use os.makedirs() in Python to create directories recursively
Use mkdirs() in Java to create directories recursively
Q92. Garbage collection algorithms
Garbage collection algorithms manage memory in programming languages by automatically reclaiming unused memory.
Garbage collection is used in languages like Java, C#, and Python to automatically free up memory.
There are different algorithms like mark and sweep, reference counting, and generational collection.
Mark and sweep algorithm involves marking reachable objects and then sweeping away the unmarked ones.
Reference counting algorithm counts references to objects and dealloca...read more
Q93. 20) Full booting procedure
The full booting procedure is the sequence of steps that a computer system goes through to start up and become operational.
Power on the computer
Perform the Power-On Self-Test (POST)
Load the Basic Input/Output System (BIOS)
Initialize hardware components
Load the operating system
Initialize software components
Display the login screen or desktop
Q94. Design a chess game
Q95. Design rate Maze Problem
Design a maze problem with varying difficulty levels.
Start by designing a simple maze with one entrance and one exit.
Increase difficulty by adding dead ends, loops, and multiple paths.
Include obstacles like walls or traps to make the maze more challenging.
Consider adding different levels with increasing complexity for players to progress through.
Provide hints or clues for players to navigate through the maze.
Allow for customization options such as maze size, shape, and theme....read more
Q96. 12)Assembly language output
Assembly language output refers to the machine code generated by an assembler from assembly language code.
Assembly language is a low-level programming language that is closely related to machine code.
The output of an assembler is typically in the form of machine code instructions that can be directly executed by a computer.
Assembly language output is specific to the architecture of the target processor.
Example: MOV AX, 5h - this assembly language instruction would be translat...read more
Q97. Convex Hull problem
The Convex Hull problem involves finding the smallest convex polygon that encloses a set of points.
The Convex Hull is the smallest convex polygon that encloses all given points.
Common algorithms for solving the Convex Hull problem include Graham's scan and Jarvis march.
The Convex Hull problem is often used in computer graphics, image processing, and computational geometry.
Q98. Reverse a string.
Q99. 5 yr plan
My 5-year plan involves advancing my career through continuous learning and professional development.
Continuously seek out new learning opportunities and certifications
Set specific career goals and milestones to track progress
Network with industry professionals and mentors for guidance
Regularly reassess and adjust the plan based on career developments
Q100. Explain adam optimizer
More about working at Adobe
Top HR Questions asked in YDTS India
Interview Process at YDTS India
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month