Skip to main content

Timeline for Reversing vowels in a string

Current License: CC BY-SA 4.0

8 events
when toggle format what by license comment
Jul 5 at 23:29 comment added Eman Yalpsid @nocomment That's smart. Great! Yep, it's by far the fastest (~16 ms in the context of my answer).
Jul 5 at 19:23 comment added no comment (That wins my answer's benchmark with ~2.9 ms... I'll include it later.)
Jul 5 at 19:12 comment added no comment Try this.
Jul 5 at 18:49 comment added no comment Or use a lookup-array with 128 bools telling whether the characters are a vowel.
Jul 5 at 18:46 comment added no comment And for the mask, it might be faster to not use a set but find each vowel's locations separately and "or" them.
Jul 5 at 18:39 comment added no comment If you assume ASCII like it is on LeetCode, you could encode the string to bytes and create a NumPy array from that. That should be fast.
Jul 5 at 17:55 history edited Eman Yalpsid CC BY-SA 4.0
Wasn't happy with my codes. Tried to do some actual code-review. Please ignore the thread-bump.
Jul 4 at 18:55 history answered Eman Yalpsid CC BY-SA 4.0