you give string text you swap character textreturn length long substre repeat character example 1input text ababaoutput 3explanation we swap b b then long repeat character substring aaa length 3example 2input text aaabaaaoutput 6explanation Swap b long repeat character substring aaaaaa length 6example 3input text aaaaaoutput 5explanation no need swap long repeat character substre aaaaa length 5 constraints1 textlength 2 104text consist lowercase english character