Oops!! It seems some javascript files did not load. Please hard reload(SHIFT + reload) your page.

Israel Tsadok

Sergey Kharagorgiev

What to expect at Adobe Interview?

Be able to discuss the big-O complexity of your approaches. Don't forget to brush up on your data structures like lists, arrays, hash tables, hash maps,
stacks, queues, graphs, trees, heaps. Also sorts, searches, and traversals(BFS, DFS). Also review recursion and iterative approaches.

Use the programming language you're best at. It's important to write your solution correctly and in time, so use the language you are most familiar with.

Find and fix the bugs by yourself: Don't wait for the interviewer to find them for you.

Use the hints you are given: Usually, the interviewer knows the question well enough to know which hints will help you next if you get stuck.

Find and fix the bugs by yourself: Don't wait for the interviewer to find them for you.

Use the hints you are given: Usually, the interviewer knows the question well enough to know which hints will help you next if you get stuck.

Solve Interview Problems asked at Adobe

Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

push(x)– Push element x onto stack.pop()– Removes the element on top of the stack.top()– Get the top element.getMin()– Retrieve the minimum element in the stack.

Note that all the operations have to be constant time operations.

Questions to ask the interviewer :

```
Q: What should getMin() do on empty stack?
A: In this case, return -1.
Q: What should pop do on empty stack?
A: In this case, nothing.
Q: What should top() do on empty stack?
A: In this case, return -1
```

NOTE: If you are using your own declared global variables, make sure to clear them out in the constructor.

Solve Now

Grid Unique Paths

A robot is located at the top-left corner of an **A x B grid** (marked ‘Start’ in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).

How many possible unique paths are there?

*Note: A and B will be such that the resulting answer fits in a 32 bit signed integer.*

**Example :**

```
Input : A = 2, B = 2
Output : 2
2 possible routes : (0, 0) -> (0, 1) -> (1, 1)
OR : (0, 0) -> (1, 0) -> (1, 1)
```

Solve Now

Combination Sum

Given a set of candidate numbers `(C)`

and a target number `(T)`

, find all unique combinations in `C`

where the candidate numbers sums to `T`

.

The same repeated number may be chosen from `C`

unlimited number of times.

Note:

- All numbers (including target) will be positive integers.
- Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak).
- The combinations themselves must be sorted in ascending order.
- CombinationA > CombinationB iff (a
_{1}> b_{1}) OR (a_{1}= b_{1}AND a_{2}> b_{2}) OR … (a_{1}= b_{1}AND a_{2}= b_{2}AND … a_{i}= b_{i}AND a_{i+1}> b_{i+1})- The solution set must not contain duplicate combinations.

**Example**,

Given candidate set `2,3,6,7`

and target `7`

,

A solution set is:

```
[2, 2, 3]
[7]
```

Warning :DO NOT USE LIBRARY FUNCTION FOR GENERATING COMBINATIONS.

Example : itertools.combinations in python.

If you do, we will disqualify your submission retroactively and give you penalty points.

Solve Now

Permutations

Given a collection of numbers, return all possible permutations.

**Example:**

`[1,2,3]`

will have the following permutations:

```
[1,2,3]
[1,3,2]
[2,1,3]
[2,3,1]
[3,1,2]
[3,2,1]
```

NOTE

- No two entries in the permutation sequence should be the same.
- For the purpose of this problem, assume that all the numbers in the collection are unique.

Warning :DO NOT USE LIBRARY FUNCTION FOR GENERATING PERMUTATIONS.

Example : next_permutations in C++ / itertools.permutations in python.

If you do, we will disqualify your submission retroactively and give you penalty points.

Solve Now

Combinations

Given two integers `n`

and `k`

, return all possible combinations of `k`

numbers out of `1 2 3 ... n`

.

Make sure the combinations are **sorted**.

To elaborate,

- Within every entry, elements should be sorted.
`[1, 4]`

is a valid entry while`[4, 1]`

is not. - Entries should be sorted within themselves.

**Example :**

If `n = 4`

and `k = 2`

, a solution is:

```
[
[1,2],
[1,3],
[1,4],
[2,3],
[2,4],
[3,4],
]
```

Warning :DO NOT USE LIBRARY FUNCTION FOR GENERATING COMBINATIONS.

Example : itertools.combinations in python.

If you do, we will disqualify your submission retroactively and give you penalty points.

Solve Now

Merge Two Sorted Lists II

Given two sorted integer arrays A and B, merge B into A as one sorted array.

Note: You have to modify the array A to contain the merge of A and B. Do not output anything in your code.

TIP: C users, please malloc the result into a new array and return the result.

If the number of elements initialized in A and B are `m`

and `n`

respectively, the resulting size of array A after your code is executed should be `m + n`

**Example :**

```
Input :
A : [1 5 8]
B : [6 9]
Modified A : [1 5 6 8 9]
```

Solve Now

Valid Number

Validate if a given string is numeric.

**Examples:**

`"0" => true`

`" 0.1 " => true`

`"abc" => false`

`"1 a" => false`

`"2e10" => true`

Return `0 / 1`

( 0 for false, 1 for true ) for this problem

**Clarify the question using “See Expected Output”**

Is 1u ( which may be a representation for unsigned integers valid?

For this problem, no.Is 0.1e10 valid?

Yes-01.1e-10?

YesHexadecimal numbers like 0xFF?

Not for the purpose of this problem

`3.`

(. not followed by a digit)?

NoCan exponent have decimal numbers? 3e0.1?

Not for this problem.Is 1f ( floating point number with f as prefix ) valid?

Not for this problem.How about 1000LL or 1000L

( C++ representation for long and long long numbers )?

Not for this problem.How about integers preceded by 00 or 0? like 008?

Yes for this problem

Solve Now

Atoi

Implement atoi to convert a string to an integer.

**Example :**

```
Input : "9 2704"
Output : 9
```

*Note: There might be multiple corner cases here. Clarify all your doubts using “See Expected Output”.*

Questions:

Q1.Does string contain whitespace characters before the number?

A.Yes

Q2.Can the string have garbage characters after the number?

A.Yes. Ignore it.

Q3.If no numeric character is found before encountering garbage characters, what should I do?

A.Return 0.

Q4.What if the integer overflows?

A.Return INT_MAX if the number is positive, INT_MIN otherwise.

**Warning : DO NOT USE LIBRARY FUNCTION FOR ATOI.**

*If you do, we will disqualify your submission retroactively and give you penalty points.*

Solve Now

Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of `1`

bits it has.

**Example:**

The 32-bit integer `11`

has binary representation

```
00000000000000000000000000001011
```

so the function should return `3`

.

*Note that since Java does not have unsigned int, use long for Java*

Solve Now

Least Common Ancestor

Find the lowest common ancestor in an unordered binary tree given two values in the tree.

Lowest common ancestor :the lowest common ancestor (LCA) of two nodes`v`

and`w`

in a tree or directed acyclic graph (DAG) is the lowest (i.e. deepest) node that has both`v`

and`w`

as descendants.

**Example :**

```
_______3______
/ \
___5__ ___1__
/ \ / \
6 _2_ 0 8
/ \
7 4
```

For the above tree, the LCA of nodes `5`

and `1`

is `3`

.

LCA= Lowest common ancestor

Please note that LCA for nodes `5`

and `4`

is `5`

.

- You are given 2 values. Find the lowest common ancestor of the two nodes represented by
`val1`

and`val2`

- No guarantee that
`val1`

and`val2`

exist in the tree. If one value doesn’t exist in the tree then return -1.- There are no duplicate values.
- You can use extra memory, helper functions, and can modify the node struct but, you can’t add a parent pointer.

Solve Now