# Adobe Interview Experience for Computer Scientist-1

• Difficulty Level : Easy
• Last Updated : 12 May, 2021

Adobe interview Experience for CS-1, Bangalore location. I’ll share my experience in this post . I have around 5 years of experience working as a Java Developer(Backend). The interview was conducted as part of their hiring drive and all the interview rounds were online . The interviewers were very helpful.

Round 1:

1. Given a sorted array having all the unique elements. and a target Sum. Find whether there exists a pair of elements in the array with the sum as the targetSum.
```eg:
Arr={4, 5, 8, 10, 12, 15, 20}  targetSum = 23
Op: Yes. (8, 15)```

## Java

 `/*package whatever //do not write package name here */`` ` `public` `int``[] findPair(``int``[] arr, ``int` `sum)`` ` `{``    ``int``[] res = ``new` `int``[``2``];``    ``int` `l = ``0``;``    ``int` `r = arr.length - ``1``;``    ``while` `(l < r) {``        ``int` `temp = arr[l] + arr[r];``        ``if` `(temp > sum)``            ``r--;``        ``else` `if` `(temp < sum)``            ``l++;``        ``else` `{``            ``res[``0``] = arr[l];``            ``res[``1``] = arr[r];``            ``break``;``        ``}``    ``}``    ``return` `res;``}`

2. Given an Unbalanced Binary Search Tree. Find the Second highest element in the tree.

## Java

 `/*package whatever //do not write package name here */`` ` `Node getSecondMax(Node root) { ``return` `util(root, ``null``); }`` ` `Node util(Node root, Node prev)``{``    ``if` `(root == ``null``)``        ``return` `root;`` ` `    ``if` `(root.right != ``null``) {``        ``prev = root;``        ``return` `util(root.right, prev);``    ``}``    ``else` `{``        ``if` `(root.left == ``null``)``            ``return` `prev;``        ``else``            ``return` `getRight(root.left);``    ``}``}`` ` `Node getRight(Node root)``{``    ``if` `(root == ``null``)``        ``return` `root;`` ` `    ``if` `(root.right == ``null``)``        ``return` `root;`` ` `    ``if` `(root.right != ``null``)``        ``return` `getRight(root.right);``}`

Round 2: System Design

1. Design an Online Playlist having the following functionalities exposed to the end user.
• search by artist name/song name/genre/year of release/album name
• sort by year of release/no. of hits(likes)
• recommend similar playlist
• resumePlaylist from lastsaved point

Round 3: Manager Round

1. Given an array of Unsorted integers and a value k. Find the k smallest elements from the array.
```eg: arr={6,3,6,2,2,4,7}  k=4
op: 2,2,3,4```

## Java

 `/*package whatever //do not write package name here */`` ` `public` `void` `kSmallestElements(``int``[] arr, ``int` `k)`` ` `{``    ``// Max heap``    ``PriorityQueue pq = ``new` `PriorityQueue(``        ``Collections.reverseOrder());``    ``if` `(k >= arr.length) {``        ``for` `(``int` `i : arr)``            ``System.out.print(i + ``" "``);``        ``return``;``    ``}`` ` `    ``for` `(``int` `i = ``0``; i < k; i++) {``        ``pq.add(arr[i]);``    ``}`` ` `    ``for` `(``int` `i = k; i < arr.length; i++) {``        ``int` `max = pq.peek();``        ``if` `(arr[i] < max) {``            ``pq.poll();``            ``pq.add(arr[i]);``        ``}``    ``}`` ` `    ``for` `(``int` `i = ``0``; i < k; i++) {``        ``System.out.print(pq.poll() + ``" "``);``    ``}``}`

2. System Design: Design an online Flight reservation system having the features:
• Searching for flights between destinations on a given date
• book the flight
• retrieve the bookings of a user
3. Round 4:

• The final round was taken by a senior person, maybe the director of engineering, and he asked me to design the system where multiple users are booking for a same seat in apps such as BookMyShow. How to handle the concurrency when multiple users want to book the same resource simultaneously.

Result: I got a call from HR after 2 days saying that I was selected.

My Personal Notes arrow_drop_up