runlength encoding string compression method work replace consecutive identical character repeat 2 time concatenation character number mark count character length run for example compress string aabccc replace aa a2 replace ccc c3 thus compress string a2bc3notice problem add 1 single charactersgiven string s integer k you need delete k character s runlength encode version s minimum lengthfind minimum length runlength encode version s delete k character Example 1input s aaabcccd k 2output 4explanation compress s delete a3bc3d length 6 delete character c decrease length compressed string 5 instance delete 2 s abcccd compress abc3d therefore optimal way delete b d compress version s a3c3 length 4example 2input s aabbaa k 2output 2explanation if delete b character result compressed string a4 length 2example 3input s aaaaaaaaaaa k 0output 3explanation since k zero delete the compressed string a11 length 3 constraints1 slength 1000 k slength contain lowercase english letter