Created
May 18, 2023 16:18
-
-
Save nadeemelahi/1cf305084a2f6637d7e949cb25191369 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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