Interviewing at Adobe — Software Engineering Online Assessment

Adi S
Adi S
Feb 18 · 2 min read
Source: inkhive.com

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.

Good luck!

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: 4
Output: 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 = 4

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!

JavaScript in Plain English

Learn the web's most important programming language.

Adi S

Written by

Adi S

JavaScript in Plain English

Learn the web's most important programming language.

More From Medium

More from JavaScript in Plain English

More from JavaScript in Plain English

More from JavaScript in Plain English

32 funny Code Comments that people actually wrote

10.3K

More from JavaScript in Plain English

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