give array character chars compress follow algorithmbegin string s for group consecutive repeat character charsIf group length 1 append character sOtherwise append character follow group lengththe compress string s return separately instead store input character array char note group length 10 long split multiple character charsafter modify input array return new length arrayyou write algorithm use constant extra space Example 1input char aabbcccOutput Return 6 6 character input array a2b2c3explanation the group aa bb ccc this compress a2b2c3example 2input char aOutput return 1 character input array aExplanation the group remain uncompressed single characterexample 3input char abbbbbbbbbbbboutput return 4 4 character input array ab12explanation the group bbbbbbbbbbbb this compress ab12 Constraints1 charslength 2000charsi lowercase english letter uppercase english letter digit symbol