Unexpected output for all characters to be removed


#1

why does it output “aaaaaaaa” for an input string “aaaaaaaa” and integer =4?


#2

The question states “length exactly B”