diff --git a/build/classes/TechInterview/FirstNonRepeated.class b/build/classes/TechInterview/FirstNonRepeated.class new file mode 100644 index 0000000..a52987c Binary files /dev/null and b/build/classes/TechInterview/FirstNonRepeated.class differ diff --git a/src/TechInterview/FirstNonRepeated.java b/src/TechInterview/FirstNonRepeated.java new file mode 100644 index 0000000..da44049 --- /dev/null +++ b/src/TechInterview/FirstNonRepeated.java @@ -0,0 +1,56 @@ +/*** + +Given a string s consisting of lowercase Latin Letters, find the first non repeating character in s. + +Input: + +The first line contains T denoting the number of testcases. Then follows description of testcases. +Each case begins with a single integer N denoting the length of string. The next line contains the string s. + +Output: + + + For each testcase, print the first non repeating character present in string. + + Print -1 if there is no non repeating character. + +***/ + +import java.util.*; +import java.lang.*; +import java.io.*; + +class FirstNonRepeated { + public static void main (String[] args) { + + + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0) + { + Map map= new HashMap<>(); + int n = sc.nextInt(); + String s = sc.next(); + + for(int i=0;i