We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The problem description reads, "In this task you'll be given a permutation" -- but test case #2 is the non-permutation (5 1 2 4 3 2). As the problem is currently stated, that test case constitutes invalid input. My first attempt, which I believe is correct, failed because I intentionally checked for and rejected (via assertion) inputs that were not bijective. I had to delibrately make my code less robust so it would pass the test. That succeeded.
This could be fixed either by replacing the test case or by modifying the problem statement so that it no longer stipulates that the input will be a permutation.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Security Involution
You are viewing a single comment's thread. Return to all comments →
The problem description reads, "In this task you'll be given a permutation" -- but test case #2 is the non-permutation (5 1 2 4 3 2). As the problem is currently stated, that test case constitutes invalid input. My first attempt, which I believe is correct, failed because I intentionally checked for and rejected (via assertion) inputs that were not bijective. I had to delibrately make my code less robust so it would pass the test. That succeeded.
This could be fixed either by replacing the test case or by modifying the problem statement so that it no longer stipulates that the input will be a permutation.