Commonly asked Data Structures and Algorithms Problems by big tech and different solution approaches with code in Java and C

Powered by Blogger.

Wednesday, June 14, 2017

Two Characters Hackerrank solution Algo in O(n)


You need two methods :


1: to validate the string that if it passes the case (it should not have repeated chars)



2: delete chars


here create a arraylist and insert all the string char in it and iterate over arraylist whenever a continuous two elements found , delete its all the occurrence from arraylist by get() method and remove() by passing index and at the end of string validate it . do it until it gets passed

0 Comments:

Post a Comment

Stats