Can you solve this interview problem?

So few days ago I applied to a MNC and I had some interesting problems to solve in given amount of time. So let me share one with you, see if you can solve this.

Problem Description

So let’s say we have a URL something like this:

let url…


This content originally appeared on DEV Community and was authored by Shuvo

So few days ago I applied to a MNC and I had some interesting problems to solve in given amount of time. So let me share one with you, see if you can solve this.

Problem Description

So let's say we have a URL something like this:

let url = "https://dev.to/0shuvo0"

Now they have converted the url to a base64 string.
So the URL have become something like this:

let url = "aHR0cHM6Ly9kZXYudG8vMHNodXZvMA=="

Now what they did was split the sting to multiple parts and convert into an array

let url = ["aHR0cH", "M6Ly9kZX", "YudG8vMHN", "odXZvMA=="]

But of course the madnesses doesn't stop here. Then the shuffled the array so it became something like this:

let url = ["M6Ly9kZX", "aHR0cH", "odXZvMA==", "YudG8vMHN"]

And lastly they have converted that array to a string.

So here is your input

let url = "[ '0LzFqZTFt', '9jb21tZW5', '8vMHNodXZvMC', '6Ly9kZXYudG', 'aHR0cHM' ]"

Use the input to find the original URL programmatically you have 45 Minutes to do it.

Useful JavaScript functions that can help you

  • You can convert your array to sting by calling join method on it. Eg.
let urlStr = url.join("")
  • You can use atob function to decode the base64 string.
let decoded = atob(urlStr)

Now go and and see if you can solve this. Best of luck 👍

.ltag__user__id__728097 .follow-action-button { background-color: #000000 !important; color: #ffffff !important; border-color: #000000 !important; }
0shuvo0 image

Was it useful? Support me on Patreon

Patreon Logo


This content originally appeared on DEV Community and was authored by Shuvo


Print Share Comment Cite Upload Translate Updates
APA

Shuvo | Sciencx (2021-11-04T05:29:04+00:00) Can you solve this interview problem?. Retrieved from https://www.scien.cx/2021/11/04/can-you-solve-this-interview-problem/

MLA
" » Can you solve this interview problem?." Shuvo | Sciencx - Thursday November 4, 2021, https://www.scien.cx/2021/11/04/can-you-solve-this-interview-problem/
HARVARD
Shuvo | Sciencx Thursday November 4, 2021 » Can you solve this interview problem?., viewed ,<https://www.scien.cx/2021/11/04/can-you-solve-this-interview-problem/>
VANCOUVER
Shuvo | Sciencx - » Can you solve this interview problem?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/04/can-you-solve-this-interview-problem/
CHICAGO
" » Can you solve this interview problem?." Shuvo | Sciencx - Accessed . https://www.scien.cx/2021/11/04/can-you-solve-this-interview-problem/
IEEE
" » Can you solve this interview problem?." Shuvo | Sciencx [Online]. Available: https://www.scien.cx/2021/11/04/can-you-solve-this-interview-problem/. [Accessed: ]
rf:citation
» Can you solve this interview problem? | Shuvo | Sciencx | https://www.scien.cx/2021/11/04/can-you-solve-this-interview-problem/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.