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.
I'm pretty sure I've figured it out.. here is each part in key explained-
`
1. if isdigit, give higher priority. so alphas come before digits now
Ex- Sorting1234 => Sorting1234
2. if isevendigit, give higher priority. so, among the digits, now even have higher priority. While the 1st part in key is maintained
Ex- Sorting1234 => Sorting1324
3. next priority goes to upper case keeping both previous keys maintained. so uppercase can't go after the numbers as that key has higher priority.
Ex - Sorting1234 => ortingS1324
4. next priority is given to lowercase characters, but that isn't required as it's the only ones left in alphanumeric characters. We will get the same output either way
Ex - Sorting1234 => ortingS1324
5. now sort according to the characters, but keeping all the previous keys in mind, all the characters will be sorted in place, keeping their order as defined in previous keys
Ex - Sorting1234 => ginortS1324
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
ginortS
You are viewing a single comment's thread. Return to all comments →
I'm pretty sure I've figured it out.. here is each part in key explained-
`
1. if isdigit, give higher priority. so alphas come before digits now 2. if isevendigit, give higher priority. so, among the digits, now even have higher priority. While the 1st part in key is maintained 3. next priority goes to upper case keeping both previous keys maintained. so uppercase can't go after the numbers as that key has higher priority. 4. next priority is given to lowercase characters, but that isn't required as it's the only ones left in alphanumeric characters. We will get the same output either way 5. now sort according to the characters, but keeping all the previous keys in mind, all the characters will be sorted in place, keeping their order as defined in previous keys