14

I'm curious...is there a practical application for reversing a string, other than for tutorials and interview questions?

Comments
  • 3
    If you are trying to learn pig Latin but you keep getting attacked by a unicorn, you might need to reverse a string to keep the bed bugs at bay.
  • 4
    dealing with endianness
  • 8
    Some langs do not have an indexof that can search from the end of a string.
    Instead if rolling your own you reversed both strings and used the normal index of.

    Not the optimal performance but easier than building your own string match.
  • 1
    I always test that with the dutch word 'parterretrap' // works on my machine
  • 0
    @karma you could test that with an empty function and it'd still work. Fun fact : Palindrome is not a palindrome
  • 3
    In SQL if you need to trim the end of a string it's way easier to reverse the string and remove the characters from the front then reverse it again. It's not impossible to do it the other way but good lord is it a hassle.
  • 0
    string[::-1]

    Python bitch 😎
  • 0
    Well, I just reversed a string as part of comma injection for numbers. Guess I answered my own question.
  • 0
    Push each character to array
    Reverse array
    Flatten array
    Done
Add Comment