Given a non-empty string, find out the character that has second-highest frequency of occurrence in the string.
If there are no such characters, print -1
If there are multiple such characters, print the lexicographically smallest of them. ( As per their ASCII value)
First line contains a single integer corresponding to integer N. ( Size of string )
Second line contains N-sized string.
Constraints
$$$ 1 \le N \le 1000000 $$$
The characters in the string could be any valid ASCII character.
A single character having the second-highest frequency and lexicographically smallest if there are multiple characters of the same frequency.
aaaaaa
-1
nkslanfaaboutcec
c
`SgkEBzNnH
-1
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.