# Interviewing at Adobe — Software Engineering Online Assessment

Feb 18 · 2 min read

This week let’s take a look at 2 questions from Adobe’s online assessment. This was from 2019 so it might have changed in 2020.

Both of these are considered “easy” but obviously that will depend on your knowledge and practice with algorithms.

## Question 1

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.

Example:

`Input: 4Output: false Explanation: If there are 4 stones in the heap, then you will never win the game;             No matter 1, 2, or 3 stones you remove, the last stone will always be              removed by your friend.`

Think about: If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner?

Note: This can be solved with time complexity O(1) and space complexity O(1).

## Question 2

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

If you are not familiar with Hamming distance please check out the Wikipedia description.

Given two integers `x` and `y`, calculate the Hamming distance.

Note:
0 ≤ `x`, `y` < 231.

Example:

`Input: x = 1, y = 4Output: 2Explanation:1   (0 0 0 1)4   (0 1 0 0)       ↑   ↑The above arrows point to positions where the corresponding bits are different.`

The Hamming distance between two integer numbers is the number of positions at which the corresponding bits are different.

Note: Like the example above this can also be solved with time complexity O(1) and space complexity O(1).

As always please post your JS solutions in the comments and any questions. After most of you have had a chance to give it a try, I will post my solutions. And remember, if these are difficult to solve, don’t worry keep practicing and it will get easier!

Written by

## More From Medium

#### More from JavaScript in Plain English

Mar 30 · 7 min read

### 32 funny Code Comments that people actually wrote

Mar 3 · 9 min read

### The Top 6 JavaScript frameworks for 2020

Mar 20 · 5 min read

#### 535

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just \$5/month. Upgrade