Timeline for Finding first unique character in string
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 4, 2022 at 18:47 | comment | added | G. Sliepen |
@Deduplicator I just wanted to focus on presenting a very simple, one-pass solution here. You're right that a std::string_view would be better, or perhaps even make this a range-algorithm itself that works on any container, although in that case using a std::array might no longer be viable.
|
|
| Sep 4, 2022 at 16:48 | comment | added | Deduplicator |
I guess you used std::array to get .fill() instead of just std::fill() and std::ranges::fill(). Any reason you didn't recommend std::string_view?
|
|
| Sep 4, 2022 at 12:19 | vote | accept | tarstevs | ||
| Sep 4, 2022 at 10:06 | comment | added | G. Sliepen | No problem. Note that you can always change the accepted answer if you decide another answer is better. | |
| Sep 4, 2022 at 9:47 | comment | added | tarstevs | The algorithm was complete from the start, but I accidentally left a detail out of the text until now: The part I forgot to "write up" until just now was that -1 should be returned if there is no unique char. This is a very minor point. Anyways, it seems to me that @janos submitted his answer quite a while ago and that he is going to add some details to make it a bit more clear. If he does I'm under the impression that I should accept his answer. Otherwise I'll accept this one. Not sure if you or he care much, just wanted to get current. | |
| Sep 4, 2022 at 9:44 | history | edited | G. Sliepen | CC BY-SA 4.0 |
added 75 characters in body
|
| Sep 4, 2022 at 9:37 | history | edited | G. Sliepen | CC BY-SA 4.0 |
deleted 167 characters in body
|
| Sep 4, 2022 at 9:29 | history | edited | G. Sliepen | CC BY-SA 4.0 |
added 283 characters in body
|
| Sep 4, 2022 at 9:22 | history | answered | G. Sliepen | CC BY-SA 4.0 |