ginortS - HackerRank Solution Python

Featured image

ginortS is a medium-level problem of python on Hackerrank that requires knowledge of sort in python. In this post, you will learn how to solve Hackerrank’s ginortS problem and its solution in Python.

Problem Statement and Explanation

Sort the string using the ginortS logic based on the following rules:

Input Format

Explanation of Solution

The code you provided is a Python function called ginortS(), which takes a string as input and returns a new string with the characters sorted in the following order:

The function works by first creating four empty strings: small, capital, odd, and even. It then iterates over the input string and adds each character to the appropriate string depending on its type.

Once the function has finished iterating over the input string, it sorts each of the four strings and then concatenates them together to form the output string.