Published on

Story of my Full Stack Developer Interview at Voyager Global Mobility

Authors

Technical Interview

Title: Technical Interview for the role Full Stack Developer at Voyager Global Mobility

Author: Umair Anwar

Subject: Interviews

Language: English

Source: PHP I Did, Blogspot

Introduction

Analytical Questions

1. You have three switches in one room and three bulbs connected to these switches in the second room. You can enter the second room only once. How can you determine which switch correspond to which bulb?

2. You have three boxes BB, BR and RR. BB has blue balls, BR has blue and red balls, RR has red balls. Now if the boxes are labeled incorrectly and you can only open one box to take out only one ball, how will you determine the correct labels.

Coding Problem

You have a MathChallenge(num) function which can take a number as an input. You have a coins in a sorted array [1, 5, 7, 9, 11]. It returns the minimum number of coins for sum equal to the input.

I will write its solution in Typescript. Let's create a file named mathcoin.ts and add the following code.

function MathChallenge(num: number):number
{
    const coins = [1, 5, 7, 9, 11].reverse()
    let total_coins = 0
    while(num>0){
        for(let i=0;i<coins.length; i++){
            console.log(`${total_coins}=${num}/${coins[i]}`)
            if(num%coins[i]==0){
                total_coins+=num/coins[i]
            }
            num=num%coins[i]
        }
    }
    return total_coins
}
console.log(MathChallenge(33))
console.log(MathChallenge(27))
console.log(MathChallenge(16))

Let's compile this code using the command below

tsc mathcoin.ts

As soon as you run the command you will see another file created mathcoin.js. To execute the code, run this command;

node mathcoin.js