dUPLICATE character formatting

how to check whether charACTER IS dUPLICATE or not??

Algorithm:

  • Obtain the result for substring starting at index 1. Store this in another string , say β€˜ros’ .
  • Check whether the first character of current string and first character of ros are same.
  • If so return , add a " * " to the new result and concatenate as s[0] + " * " + ros.
  • Else simply return s[0] + ros.