Quantcast
Channel: First non repeated character - Code Review Stack Exchange
Browsing latest articles
Browse All 5 View Live

Answer by Marc for First non repeated character

Welcome to Code Review. There are already excellent answers, I am adding an alternative solution running in \$O(n)\$ and relatively simple to understand.private static void...

View Article



Answer by Dorian Gray for First non repeated character

I would do it without the additional set as follows. Basically same approach as here, but with a different return value.public class FirstNonRepeatedChar { public static void main(String[] args) {...

View Article

Answer by greybeard for First non repeated character

One point I don't find addressed in Joop Eggen's answer:don't write, never present un(doc)commented codeMy take is entirely similar to his, isolating determination of the result from use: /** @return...

View Article

Answer by Joop Eggen for First non repeated character

There are some weak spots, but an optimal algorith would need:To check all characters for unique ones.So:Optional<Character> firstNonRepeatingChar(String s) { Set<Character> candidates =...

View Article

First non repeated character

Problem Statement :Print the first non repeating character in a string.Example :In the string somecharsjustdon'tliketorepeat, m is the first non-repeating charecter.My attempt :New Code : Old one was...

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images