Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadeemelahi/1cf305084a2f6637d7e949cb25191369 to your computer and use it in GitHub Desktop.
Save nadeemelahi/1cf305084a2f6637d7e949cb25191369 to your computer and use it in GitHub Desktop.
public class Main {
public static void main(String[] args) {
String inputString = "test input string for first non repeating char z";
String uniqueCharInInputStringString;
int len = inputString.length();
char testChar;
boolean foundDuplicate;
for ( int i = 0 ; i < len; i++ ){
char testChar = inputString.charAt(i);
foundDuplicate = false;
for ( j = 0; j < len - i ; j++ ){
if ( testChar == inputString.charAt(j) ) {
foundDuplicate = true;
break;
}
}
if ( !foundDuplicate ) {
uniqueCharInInputStringString = Character.toString(testChar);
break;
}
}
System.out.println( uniqueCharInInputStringString );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment