KANNIS - editorial

PROBLEM LINK:

Practice
Contest

KANNIS PARADOX

PROBLEM CODE: KANNIS

DIFFICULTY: Easy

The problem demands that the array be sorted and printed. Here the test cases and time limits were designed in such a way that only efficient sorting algorithms like merge sort, and heap sort alone would pass. The default sort() function present in <algorithms.h> in c++ would also do the task efficiently.

Time Complexity: O(n*logn)

Since there are only 3 distinct characters present in the array (A, R, S ) one can count the no of As, Rs, and Ss and printed the characters their respective no of occurrences in order. The author’s solution does the same.

Setter’s solution: Solution