Welcome to my personal website. I use this space to share some of my thoughts and software that I write in my free time. Sometimes I also publish photos. If you want to get in touch please use LinkedIn or Mastodon.
Reverse a string and only use one extra variable. The solution is straightforward with two pointers, p1 and p2. THe idea here is to start from both ends and increment p1 and decrement p2 until both of them meet in the middle. To switch the values of variables without assigning a temporary variable, the notation of a, b = b, a can be used. To convert a string into a list of characters, surroung the string with [*s].
Runtime: 377 ms, faster than 22.88% of Python3 online submissions for Reverse String.
Memory Usage: 18.4 MB, less than 45.70% of Python3 online submissions for Reverse String.
About the author
Friedrich Ewald is an experienced Software Engineer with a Master's degree in Computer Science. He started this website in late 2015, mostly as a digital business card. He is interested in Go, Python, Ruby, SQL- and NoSQL-databases, machine learning and AI and is experienced in building scalable, distributed systems and micro-services at multiple larger and smaller companies.