Ad
  • Custom User Avatar

    What happens if the string were "The hat he was wearing was gray"? Your algorithm would lead to

    "heTay" -> "heTay athay" -> "ehayTay athay ehay"
                                 ^^^^^^^
    

    Also, the duplicate "was" would lead to interesting problems.