Amazon | OA 2021 | Hackerrank
Anonymous User
13026

Interesting that Amazon is using Hackerrank instead of AMCAT now.

First question:
exact same question as this one: https://leetcode.com/discuss/interview-question/1475585/Amazon-or-OA-or-Minimum-Coin-Flips

Second question:
Similar to this question but with some pretty big difference.
https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together/

The amazon question is given an array of only 1s and 0s where you can only make adjacent swaps, return the min number of swaps required to have all 1s or 0s on one side.

Eg. [0, 1, 0, 1] would return 1 since it takes 1 swap to have it as [0, 0, 1, 1] which is the minimum.
[1, 1, 0, 0] would be a valid array except it is not in the minimum as it would take 3 swaps.

Would be interesting to see what people can come up with second one since I didn't manage to pass all test cases for second question.

Comments (9)