Hackerrank - Two Characters

Hackerrank - Problem Statement

A description of the problem can be found on Hackerrank.

Solution

I started with finding all unique characters.
Then I created all possible combinations of pairs.

  • I deleted other characters except the pair.
  • I found if the examined pair contains alternating characters in deleted strings
  • If yes I count the length of the string.

The result is the maximum of string lengths.

I created solution in:

All solutions are also available on my GitHub profile.

Scala

Java

Javascript

Leave a Reply