Amazon | OA | SDE 1
Anonymous User
5515

Took an Online Assessment via HackerRank. 2 coding questions 90 minutes. 15 min "systems design" and work style multiple choice assessment. 5 min personality test.

Coding questions are as follows:

  1. Given a binary string, return the minimum number of swaps needed to make the binary string a palindrome.

  2. Given an array rank of size n. All elements are integers from 1 to n. Return the total number of imbalances of all possible subarrays. An imbalance occurs when we take a subarray of rank, sort it, and have two numbers in a row such that rank[i] - rank[j] > 1, where i > j.

Here are two posts further explaining this question with examples. In hindsight I did not even understand the question correctly haha so please refer to the links for clarification. Part of the reason I am posting is because I am curious as to what the question was asking for, I thought it was asking for imbalances from all possible subsequences and subarrays but I believe that's incorect based on the links, however there is discussion about what's correct. I was also pre sorting rank which may completely throw off the solution. If anyone has a proper explanation and solution to this question I would love to see it.

Comments (5)