Hackerrank - String Construction

Hackerrank - Problem Statement

A description of the problem can be found on Hackerrank.

Solution

The answer is the count of distinct characters.

If the string does not contain a specific character, only then it costs 1 dollar. Because one character is a substring. When we are able to find it in a partially created string, it does not cost anything.

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby

Leave a Reply