[
  {
    "path": "InterviewsPreparation/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<classpath>\r\n\t<classpathentry kind=\"src\" output=\"target/test-classes\" path=\"src/test/java\">\r\n\t\t<attributes>\r\n\t\t\t<attribute name=\"optional\" value=\"true\"/>\r\n\t\t\t<attribute name=\"maven.pomderived\" value=\"true\"/>\r\n\t\t</attributes>\r\n\t</classpathentry>\r\n\t<classpathentry kind=\"src\" output=\"target/classes\" path=\"src/main/java\">\r\n\t\t<attributes>\r\n\t\t\t<attribute name=\"optional\" value=\"true\"/>\r\n\t\t\t<attribute name=\"maven.pomderived\" value=\"true\"/>\r\n\t\t</attributes>\r\n\t</classpathentry>\r\n\t<classpathentry kind=\"src\" path=\"src/main/resources\"/>\r\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8\">\r\n\t\t<attributes>\r\n\t\t\t<attribute name=\"maven.pomderived\" value=\"true\"/>\r\n\t\t</attributes>\r\n\t</classpathentry>\r\n\t<classpathentry kind=\"con\" path=\"org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER\">\r\n\t\t<attributes>\r\n\t\t\t<attribute name=\"maven.pomderived\" value=\"true\"/>\r\n\t\t</attributes>\r\n\t</classpathentry>\r\n\t<classpathentry kind=\"output\" path=\"target/classes\"/>\r\n</classpath>\r\n"
  },
  {
    "path": "InterviewsPreparation/.gitignore",
    "content": "/target/\n"
  },
  {
    "path": "InterviewsPreparation/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<projectDescription>\r\n\t<name>Interviews-Preparation</name>\r\n\t<comment></comment>\r\n\t<projects>\r\n\t</projects>\r\n\t<buildSpec>\r\n\t\t<buildCommand>\r\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\r\n\t\t\t<arguments>\r\n\t\t\t</arguments>\r\n\t\t</buildCommand>\r\n\t\t<buildCommand>\r\n\t\t\t<name>org.eclipse.m2e.core.maven2Builder</name>\r\n\t\t\t<arguments>\r\n\t\t\t</arguments>\r\n\t\t</buildCommand>\r\n\t</buildSpec>\r\n\t<natures>\r\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\r\n\t\t<nature>org.eclipse.m2e.core.maven2Nature</nature>\r\n\t</natures>\r\n</projectDescription>\r\n"
  },
  {
    "path": "InterviewsPreparation/.settings/org.eclipse.core.resources.prefs",
    "content": "eclipse.preferences.version=1\r\nencoding//src/main/java=UTF-8\r\nencoding//src/test/java=UTF-8\r\nencoding/<project>=UTF-8\r\n"
  },
  {
    "path": "InterviewsPreparation/.settings/org.eclipse.jdt.core.prefs",
    "content": "eclipse.preferences.version=1\r\norg.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r\norg.eclipse.jdt.core.compiler.compliance=1.8\r\norg.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r\norg.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r\norg.eclipse.jdt.core.compiler.problem.forbiddenReference=warning\r\norg.eclipse.jdt.core.compiler.source=1.8\r\n"
  },
  {
    "path": "InterviewsPreparation/.settings/org.eclipse.m2e.core.prefs",
    "content": "activeProfiles=\r\neclipse.preferences.version=1\r\nresolveWorkspaceProjects=true\r\nversion=1\r\n"
  },
  {
    "path": "InterviewsPreparation/pom.xml",
    "content": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n  xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\r\n  <modelVersion>4.0.0</modelVersion>\r\n\r\n  <groupId>com.javaaid.interviews.preparation</groupId>\r\n  <artifactId>InterviewsPreparation</artifactId>\r\n  <version>0.0.1-SNAPSHOT</version>\r\n  <packaging>jar</packaging>\r\n\r\n  <name>InterviewsPreparation</name>\r\n  <url>http://maven.apache.org</url>\r\n\r\n  <properties>\r\n    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r\n  </properties>\r\n\r\n  <dependencies>\r\n    <dependency>\r\n      <groupId>junit</groupId>\r\n      <artifactId>junit</artifactId>\r\n      <version>3.8.1</version>\r\n      <scope>test</scope>\r\n    </dependency>\r\n  </dependencies>\r\n</project>\r\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/AnagramDifference.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.app_dynamics;\n\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class AnagramDifference {\n\t\n\t\t\tpublic static void main(String[] args) {\n\t\t\t\tAnagramDifference s=new AnagramDifference();\n\t\t\t\tScanner in = new Scanner(System.in);\n\t\t\t\tString[] a = {\"a\",\"jk\",\"abb\",\"mn\",\"abc\"} ;\n\t\t\t\tString[] b = {\"bb\",\"kj\",\"bbc\",\"op\",\"def\"};\n\t\t\t\t\t s.getMinimumDifference(a,b);\n\t\t\t\t}\n\t\t\t\n\t\t\tprivate  int[] getMinimumDifference(String[] a, String[] b) {\n\t\t\t\tint n=a.length;\n\t\t\t\tint ans[]=new int[n];\n\t\t\t\tfor(int i=0;i<n;i++) {\n\t\t\t\t\tString s1=a[i];\n\t\t\t\t\tString s2=b[i];\n\t\t\t\t\tint result=getAnagramDiff(s1,s2);\n\t\t\t\t\tans[i]=result;\n//\t\t\t\tSystem.out.println(result);\n\t\t\t}\n\t\t\t\treturn ans;\n\t\t\t}\n\t  int getAnagramDiff(String s1, String s2)\n\t\t    {\n\t\t        int count = 0;\n\t\t        int s1len=s1.length();\n\t\t        int s2len=s2.length();\n\t\t        if(s1len!=s2len)return-1;\n\t\t        int char_count[] = new int[26];\n\t\t \n\t\t        for (int i = 0; i < s1.length(); i++) \n\t\t            char_count[s1.charAt(i) - 'a']++;        \n\t\t        for (int i = 0; i < s2.length(); i++) \n\t\t            if (char_count[s2.charAt(i) - 'a']-- <= 0)\n\t\t                count++;\n\t\t         \n\t\t        return count;\n\t\t    }\n\t }"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/MeetingScheduler.java",
    "content": "/**\n * Problem Statement-\n * ------------------------------\n * There are lot of meeting which has been schedule for today and schedule of meetings has been provide based on that you need to arrange minimum rooms so that nobody has to wait for meeting room as cost of meeting room is also high, so arrange less meeting room for all the meetings.\n\t\n\tinput--> (startTime,endTime)\n\t(1,4),(2,8),(3,6)\n\toutput- 3\n\t\n\tinput--> (1,5),(2,6),(6,8),(7,9)\n\toutput-> 2\n */\npackage com.javaaid.ip.app_dynamics;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Scanner;\n\n/**\n * \n * @author Kanahaiya Gupta\n *\n */\nclass Time {\n\tprivate int inTime;\n\tprivate int outTime;\n\n\tpublic Time(int inTime, int outTime) {\n\t\tsuper();\n\t\tthis.inTime = inTime;\n\t\tthis.outTime = outTime;\n\t}\n\n\tpublic int getInTime() {\n\t\treturn inTime;\n\t}\n\n\tpublic void setInTime(int inTime) {\n\t\tthis.inTime = inTime;\n\t}\n\n\tpublic int getOutTime() {\n\t\treturn outTime;\n\t}\n\n\tpublic void setOutTime(int outTime) {\n\t\tthis.outTime = outTime;\n\t}\n\n}\n\npublic class MeetingScheduler {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint T = sc.nextInt();\n\t\tList<Time> lists = new ArrayList<Time>();\n\t\twhile (T-- > 0) {\n\t\t\tint n = sc.nextInt();\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tint in = sc.nextInt();\n\t\t\t\tint out = sc.nextInt();\n\t\t\t\tTime slot = new Time(in, out);\n\t\t\t\tlists.add(slot);\n\t\t\t}\n\t\t\tint minRoomCount = getMinRoomCount(lists);\n\t\t\tSystem.out.println(minRoomCount);\n\t\t}\n\n\t}\n\n\tprivate static int getMinRoomCount(List<Time> lists) {\n\t\tint a[] = new int[25];\n\t\tHashMap<Integer, Integer> map = new HashMap<Integer, Integer>();\n\t\tfor (Time t : lists) {\n\t\t\tmap.put(t.getOutTime(), -1);\n\t\t}\n\t\tfor (Time interval : lists) {\n\t\t\tfillArray(interval, map, a);\n\t\t}\n\t\tint max = getMax(a);\n\t\treturn max;\n\t}\n\n\tprivate static int getMax(int[] a) {\n\t\tint max = Integer.MIN_VALUE;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tmax = Math.max(max, a[i]);\n\t\t}\n\t\treturn max;\n\t}\n\n\tprivate static void fillArray(Time interval, HashMap<Integer, Integer> map, int[] a) {\n\t\tint start = interval.getInTime();\n\t\tint end = interval.getOutTime();\n\t\tint i = 0;\n\t\tif (map.containsKey(start)) {\n\t\t\ti = start+1;\n\t\t} else {\n\t\t\ti = start;\n\t\t}\n\t\tfor (; i <= end; i++) {\n\t\t\ta[i]++;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/Solution1.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.app_dynamics;\n\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class Solution1 {\n\tpublic static int maxProfit(int[] a) {\n\t\tint max_so_far = 0, curr_max = 0;\n\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\tcurr_max += a[i] - a[i - 1];\n\t\t\tcurr_max = Math.max(curr_max, 0);\n\t\t\tmax_so_far = Math.max(max_so_far, curr_max);\n\t\t}\n\t\treturn max_so_far <= 0 ? -1 : max_so_far;\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tint result = maxProfit(a);\n\t\tSystem.out.println(result);\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/UniqueWordFinder.java",
    "content": "/**\n *Problem Statement-\n *------------------------------\n *There is a file containing plain text, you need to tell whether all the unique words in whole file is present in single line or not?\n\tEx- \n\tinput->\n\ta\n\ta b\n\tb c d\n\ta b c d\n\t\n\toutput->yes\n\t\n\tinput->\n\ta\n\ta b\n\tb c d\n\ta b c d\n\te\n\t\n\toutput->no\n\tNote: treat character as words for ease\n \n */\n\npackage com.javaaid.ip.app_dynamics;\n\nimport java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\n\n/**\n * \n * @author Kanahaiya Gupta\n *\n */\npublic class UniqueWordFinder {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint T = sc.nextInt();\n\t\twhile (T-- > 0) {\n\t\t\tint lineCount = sc.nextInt();\n\t\t\tsc.nextLine();\n\t\t\tString[] lines = new String[lineCount];\n\t\t\tfor (int i = 0; i < lineCount; i++) {\n\t\t\t\tlines[i] = sc.nextLine();\n\t\t\t}\n\t\t\tboolean result = getUniqChar(lines);\n\t\t\tSystem.out.println(result ? \"YES\" : \"NO\");\n\t\t}\n\t\tsc.close();\n\t}\n\n\tprivate static boolean getUniqChar(String[] lines) {\n\t\tSet<String> gWords = new HashSet<String>();\n\t\tint globalSize = 0, localMax = 0;\n\t\tfor (String line : lines) {\n\t\t\tSet<String> lWords = new HashSet<String>();\n\t\t\tString words[] = line.split(\" \");\n\t\t\tfor (String word : words) {\n\t\t\t\tlWords.add(word);\n\t\t\t}\n\t\t\tlocalMax = Math.max(localMax, lWords.size());\n\t\t\tgWords.addAll(lWords);\n\t\t\tglobalSize = Math.max(globalSize, gWords.size());\n\t\t}\n\t\treturn (globalSize == localMax);\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/copy/Solution1.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.app_dynamics.copy;\n\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class Solution1 {\n\tpublic static int maxProfit(int[] a) {\n\t\tint max_so_far = 0, curr_max = 0;\n\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\tcurr_max += a[i] - a[i - 1];\n\t\t\tcurr_max = Math.max(curr_max, 0);\n\t\t\tmax_so_far = Math.max(max_so_far, curr_max);\n\t\t}\n\t\treturn max_so_far <= 0 ? -1 : max_so_far;\n\t}\n\n\tint maxDiff(int a[]) {\n\t\tif (a == null || a.length < 2)\n\t\t\treturn -1;\n\t\tint maxDiff = a[1] - a[0];\n\t\tint len = a.length;\n\t\tint min = a[0];\n\t\tfor (int i = 1; i < len; i++) {\n\t\t\tif (a[i] - min > maxDiff)\n\t\t\t\tmaxDiff = a[i] - min;\n\n\t\t\tif (a[i] < min)\n\t\t\t\tmin = a[i];\n\t\t}\n\n\t\treturn maxDiff <= 0 ? -1 : maxDiff;\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tint result = maxProfit(a);\n\t\tSystem.out.println(result);\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/ca/TheLightStore.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.ca;\n\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class TheLightStore {\n\n\tprivate static int getOpCount(String str1, String str2) {\n\t\tint dp[][] = new int[str1.length() + 1][str2.length() + 1];\n\t\tfor (int i = 0; i <= str1.length(); i++) {\n\t\t\tfor (int j = 0; j <= str2.length(); j++) {\n\t\t\t\tif (i == 0)\n\t\t\t\t\tdp[i][j] = j;\n\t\t\t\telse if (j == 0)\n\t\t\t\t\tdp[i][j] = i;\n\t\t\t\telse if (str1.charAt(i - 1) == str2.charAt(j - 1))\n\t\t\t\t\tdp[i][j] = dp[i - 1][j - 1];\n\t\t\t\telse {\n\t\t\t\t\tdp[i][j] = 1 + Math.min(dp[i - 1][j], Math.min(dp[i][j - 1], dp[i - 1][j - 1]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn dp[str1.length()][str2.length()];\n\t}\n\n\tpublic static void main(String args[]) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString input = sc.next();\n\t\tString output = sc.next();\n\t\tint result = getOpCount(input, output);\n\t\tSystem.out.println(result);\n\t}\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/cleartrip/StringChain.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.cleartrip;\n\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class StringChain {\n\n\tstatic int charCount = 0;\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t/*int N = sc.nextInt();\n\t\tString words[] = new String[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\twords[i] = sc.next();\n\t\t}*/\n        String[] words = new String[]{\"a\", \"b\",\"ba\", \"bca\", \"bda\", \"bdca\"};\n\n\t\tint result = calulateLongestChain(words);\n\t\tSystem.out.println(result);\n\t\tsc.close();\n\t}\n\n\t/**\n\t * @param words\n\t * @return\n\t */\n\tprivate static int calulateLongestChain(String[] words) {\n\t\tint maxLongestChainOfCharacter = 0;\n\t\tfor (String word : words) {\n\t\t\tint currentCharCount= findMaxChain(words, word, 0);\n\t\t\tmaxLongestChainOfCharacter = Math.max(maxLongestChainOfCharacter, currentCharCount);\n\n\t\t}\n\t\treturn maxLongestChainOfCharacter;\n\t}\n\n\t/**\n\t * @param word\n\t * @return\n\t */\n\tprivate static int findMaxChain(String[] words, String word, int lenCounter) {\n\t\tif (!wordsContains(words, word)) {\n\t\t\treturn 0;\n\t\t}\n\t\tlenCounter++;\n\t\tcharCount = lenCounter;\n\t\tfor (int i = 0; i < word.length(); i++) {\n\t\t\tStringBuilder sb = new StringBuilder(word);\n\t\t\tsb.delete(i, i + 1);\n\t\t\tfindMaxChain(words, sb.toString(), lenCounter);\n\t\t}\n\t\treturn charCount;\n\t}\n\n\t/**\n\t * @param string\n\t * @return\n\t */\n\tprivate static boolean wordsContains(String[] words, String string) {\n\t\tfor (String word : words) {\n\t\t\tif (word.equals(string)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/goldman_sachs/MNStringSolution.java",
    "content": "/**\n * problem statement-\n * ------------------------------------\n * Question:\n\tGiven a Pattern containing only Ns and M’s . N represents ascending and M represents descending , Each character (M or\n\tN) needs to display sequence of numbers(2 numbers) explaining the ascending or descending order (for ex: 21 -\n\t>represents descending -> M) . The second character in the pattern takes the last digit from first character and builds the\n\tsequence and so on..Please look at example section below.\n\tThere could be multiple numbers satisfying the pattern. The goal is to find out the lowest numeric value following the\n\tpattern.\n\tConstraints:\n\tInput can have maximum 8 characters\n\tOutput can have Digits from 1-9 and Digits can’t repeat.\n\tIn case of no possible output or incorrect input value (like blank /null /NON M or N character) please return -1.\n\tExample Section:\n\tInput : M\n\tOutput: 21 (2 -> 1 shows descending and possible smallest numeric value. Even 65 or 74 can qualify, but 21 being the\n\tsmallest numeric value is the correct answer)\n\tInput : MNM\n\tOutput:2143 (M represents descending 2->1 , N represents ascending 1->4 (1 is coming from last character) , M\n\trepresents descending 4->3(4 is coming from last character sequence) -- There would be many number qualifying the\n\tpattern like 3142 ,8796,6241 etc.. 2143 is the lowest numeric value for this pattern sequence.)\n */\n\npackage com.javaaid.ip.goldman_sachs;\n\nimport java.io.BufferedWriter;\nimport java.io.FileWriter;\nimport java.io.IOException;\nimport java.io.OutputStreamWriter;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class MNStringSolution {\n\tstatic PriorityQueue<Integer> heap = new PriorityQueue<Integer>();;\n\n\t/*\n\t * Complete the function below.\n\t */\n\tstatic int findPossibleSmallestNumberMatchingPattern(String pattern) {\n\t\tif (validatePattern(pattern))\n\t\t\treturn -1;\n\t\treturn Integer.parseInt(processString(pattern));\n\n\t}\n\n\t/**\n\t * @param pattern\n\t * @return\n\t */\n\tprivate static boolean validatePattern(String pattern) {\n\t\treturn (pattern.equals(\"\") || pattern == \"\" || pattern == \" \" || pattern == null\n\t\t\t\t|| getMNCount(pattern) != pattern.length());\n\t}\n\n\t/**\n\t * @param c\n\t * @return\n\t */\n\tprivate static int getMNCount(String pattern) {\n\t\tint mCount = 0, nCount = 0;\n\t\tfor (int i = 0; i < pattern.length(); i++) {\n\t\t\tif (pattern.charAt(i) == 'M') {\n\t\t\t\tmCount++;\n\t\t\t}\n\t\t\tif (pattern.charAt(i) == 'N') {\n\t\t\t\tnCount++;\n\t\t\t}\n\t\t}\n\t\treturn nCount + mCount;\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tScanner in = new Scanner(System.in);\n\t\tfinal String fileName = System.getenv(\"OUTPUT_PATH\");\n\t\tBufferedWriter bw = null;\n\t\tif (fileName != null) {\n\t\t\tbw = new BufferedWriter(new FileWriter(fileName));\n\t\t} else {\n\t\t\tbw = new BufferedWriter(new OutputStreamWriter(System.out));\n\t\t}\n\n\t\tint res;\n\t\tString pattern;\n\t\ttry {\n\t\t\tpattern = in.nextLine();\n\t\t} catch (Exception e) {\n\t\t\tpattern = null;\n\t\t}\n\n\t\tres = findPossibleSmallestNumberMatchingPattern(pattern);\n\t\tbw.write(String.valueOf(res));\n\t\tbw.newLine();\n\n\t\tbw.close();\n\t}\n\n\t/**\n\t * @param input\n\t * @return\n\t */\n\tprivate static String processString(String input) {\n\t\tString res = \"\";\n\t\tint len = input.length();\n\t\tfor (int k = 1; k <= len + 1; k++)\n\t\t\theap.add(k);\n\t\tint mCount = 0;\n\t\tint nCount = 0;\n\t\tfor (int i = 0; i < len; i++) {\n\t\t\tif (input.charAt(i) == 'M') {\n\t\t\t\tmCount = getConsecutiveCount(input, i, 'M');\n\t\t\t\tres += getElement(mCount + 1);\n\t\t\t\tmCount = 0;\n\t\t\t} else {\n\t\t\t\tres += getElement(1);\n\t\t\t\tnCount = 0;\n\t\t\t}\n\n\t\t}\n\t\treturn res + heap.poll();\n\t}\n\n\tpublic static int getConsecutiveCount(String input, int index, char ch) {\n\t\tint c = 0;\n\t\tfor (int i = index; i < input.length(); i++) {\n\t\t\tif (input.charAt(i) == ch) {\n\t\t\t\tc++;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn c;\n\n\t}\n\n\tprivate static String getElement(int k) {\n\t\tPriorityQueue<Integer> pq = new PriorityQueue<Integer>();\n\t\tint tmp = 0, c = 0;\n\n\t\twhile (k-- > 0) {\n\t\t\ttmp = heap.poll();\n\t\t\tc++;\n\t\t\tif (k > 0) {\n\t\t\t\tpq.add(tmp);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\theap.addAll(pq);\n\t\treturn tmp + \"\";\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/goldman_sachs/NonRepeatingDigitInProduct.java",
    "content": "/**\nproblem statement-\n--------------------------------\nGiven a number 'x', and a range of ‘y’ to ‘z’, please find the count of all the numbers ‘n’ in that range, such that the product of the number ‘n’ and 'x' does not contain any digit from the number ‘n’.\nGeneral Constraints: All the inputs will be integers and below 10\nE.g., if x = 2, y = 10 and z = 15, then,\n2 x 10 = 20 // Invalid, since the product contains 0 from 10.\n2 x 11 = 22 // Valid\n2 x 12 = 24 // Invalid, since the product contains 2 from 12.\n2 x 13 = 26 // Valid\n2 x 14 = 28 // Valid\n2 x 15 = 30 // Valid\nHence, the final count is 4.\nExample Input:\n2\n10\n15\nExample Output:\n4\n * \n */\npackage com.javaaid.ip.goldman_sachs;\n\nimport java.util.HashSet;\nimport java.util.Set;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class NonRepeatingDigitInProduct {\n\n\tpublic static void main(String[] args) {\n\t\tSystem.out.println(nonRepeatingDigitProductCount(0, 1111, 999999));\n\t}\n\t// Complete the\n\t// nonRepeatingDigitProductCount function below.*/\n\n\tstatic int nonRepeatingDigitProductCount(int x, int y, int z) {\n\t\tSet<Character> set1 = new HashSet<Character>();\n\t\tSet<Character> set2 = new HashSet<Character>();\n\t\tif (y > z || x == 1)\n\t\t\treturn 0;\n\n\t\tint countInValid = 0;\n\t\tfor (int i = y; i <= z; i++) {\n\n\t\t\tlong product = i * x;\n\n\t\t\tfor (char ch : (i + \"\").toCharArray())\n\t\t\t\tset1.add(ch);\n\n\t\t\tfor (char ch : (product + \"\").toCharArray())\n\t\t\t\tset2.add(ch);\n\n\t\t\tint set2Size = set2.size();\n\t\t\tset2.addAll(set1);\n\t\t\tif (set1.size() + set2Size > set2.size()) {\n\t\t\t\tcountInValid++;\n\t\t\t}\n\t\t\tset1.clear();\n\t\t\tset2.clear();\n\t\t}\n\t\treturn (z - y) - countInValid + 1;\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/goldman_sachs/NumberChecker.java",
    "content": "/**\n*problem statement-\n\t---------------------------------\n\tGiven an integer array as input, find out the integers which contains the digits 1,2,3 numbers in its formation . The order of 1,2,3 need\n\tnot be sequential.\n\tIn case multiple numbers qualifies the condition, The outcome should be ordered based on numeric value (lesser number first followed\n\tby greater number and so on..) and separated by comma.\n\tIn case no number qualifies the conditions, it should return -1.\n\tExample:\n\tInput :\n\t1456\n\t345671\n\t43218\n\t123\n\tOutput: 123,43218\n\tExplanation: In the above example, as there are 2 numbers(43218,123) which qualifies the condition, we need to sort the output in\n\tascending order seperated by comma.\n * \n */\npackage com.javaaid.ip.goldman_sachs;\n\nimport java.io.BufferedWriter;\nimport java.io.FileWriter;\nimport java.io.IOException;\nimport java.io.OutputStreamWriter;\nimport java.util.Arrays;\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class NumberChecker {\n\tstatic String findQualifiedNumbers(int[] numberArray) {\n\t\tArrays.sort(numberArray);\n\t\tString num = \"\", res = \"\";\n\t\tfor (int i : numberArray) {\n\t\t\tnum = i + \"\";\n\t\t\tif (num.indexOf(\"1\") != -1 && num.indexOf(\"2\") != -1 && num.indexOf(\"3\") != -1) {\n\t\t\t\tres += i + \",\";\n\t\t\t}\n\t\t}\n\t\treturn res.equals(\"\") ? \"-1\" : res.substring(0, res.length() - 1);\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tScanner in = new Scanner(System.in);\n\t\tfinal String fileName = System.getenv(\"OUTPUT_PATH\");\n\t\tBufferedWriter bw = null;\n\t\tif (fileName != null) {\n\t\t\tbw = new BufferedWriter(new FileWriter(fileName));\n\t\t} else {\n\t\t\tbw = new BufferedWriter(new OutputStreamWriter(System.out));\n\t\t}\n\n\t\tString res;\n\t\tint numberArray_size = 0;\n\t\tnumberArray_size = Integer.parseInt(in.nextLine().trim());\n\n\t\tint[] numberArray = new int[numberArray_size];\n\t\tfor (int i = 0; i < numberArray_size; i++) {\n\t\t\tint numberArray_item;\n\t\t\tnumberArray_item = Integer.parseInt(in.nextLine().trim());\n\t\t\tnumberArray[i] = numberArray_item;\n\t\t}\n\n\t\tres = findQualifiedNumbers(numberArray);\n\t\tbw.write(res);\n\t\tbw.newLine();\n\n\t\tbw.close();\n\t}\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/lenskart/StringGame.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.lenskart;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class StringGame {\n\tInputStream is;\n\tPrintWriter out;\n\tString INPUT = \"\";\n\n\tvoid solve() {\n\t\tfor (int T = ni(); T > 0; T--) {\n\t\t\tString in = ns();\n\t\t\tint result = getWinner(in);\n\t\t\tSystem.out.println(result == 1 ? \"Player1\" : \"Player2\");\n\t\t}\n\n\t}\n\n\t/**\n\t * @param in\n\t * @return\n\t */\n\tprivate static int getWinner(String in) {\n\t\tint a[]=new int[26];\n\t\tfor(int i=0;i<in.length();i++) {\n\t\t\tint index=in.charAt(i)-'a';\n\t\t\ta[index]++;\n\t\t}\n\t\tint c=0;\n\t\tfor(int i=0;i<26;i++) {\n\t\t\tif(a[i]!=0)\n\t\t\tc++;\n\t\t}\n\t\t\n\t\treturn (c&1)==1?1:2;\n\t}\n\n\tvoid run() throws Exception {\n\t\tis = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n\t\tout = new PrintWriter(System.out);\n\n\t\tlong s = System.currentTimeMillis();\n\t\tsolve();\n\t\tout.flush();\n\t\tif (!INPUT.isEmpty())\n\t\t\ttr(System.currentTimeMillis() - s + \"ms\");\n\t}\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tnew StringGame().run();\n\t}\n\n\tprivate byte[] inbuf = new byte[1024];\n\tpublic int lenbuf = 0, ptrbuf = 0;\n\n\tprivate int readByte() {\n\t\tif (lenbuf == -1)\n\t\t\tthrow new InputMismatchException();\n\t\tif (ptrbuf >= lenbuf) {\n\t\t\tptrbuf = 0;\n\t\t\ttry {\n\t\t\t\tlenbuf = is.read(inbuf);\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new InputMismatchException();\n\t\t\t}\n\t\t\tif (lenbuf <= 0)\n\t\t\t\treturn -1;\n\t\t}\n\t\treturn inbuf[ptrbuf++];\n\t}\n\n\tprivate boolean isSpaceChar(int c) {\n\t\treturn !(c >= 33 && c <= 126);\n\t}\n\n\tprivate int skip() {\n\t\tint b;\n\t\twhile ((b = readByte()) != -1 && isSpaceChar(b))\n\t\t\t;\n\t\treturn b;\n\t}\n\n\tprivate double nd() {\n\t\treturn Double.parseDouble(ns());\n\t}\n\n\tprivate char nc() {\n\t\treturn (char) skip();\n\t}\n\n\tprivate String ns() {\n\t\tint b = skip();\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tprivate char[] ns(int n) {\n\t\tchar[] buf = new char[n];\n\t\tint b = skip(), p = 0;\n\t\twhile (p < n && !(isSpaceChar(b))) {\n\t\t\tbuf[p++] = (char) b;\n\t\t\tb = readByte();\n\t\t}\n\t\treturn n == p ? buf : Arrays.copyOf(buf, p);\n\t}\n\n\tprivate char[][] nm(int n, int m) {\n\t\tchar[][] map = new char[n][];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tmap[i] = ns(m);\n\t\treturn map;\n\t}\n\n\tprivate int[] na(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = ni();\n\t\treturn a;\n\t}\n\n\tprivate int ni() {\n\t\tint num = 0, b;\n\t\tboolean minus = false;\n\t\twhile ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n\t\t\t;\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\n\t\twhile (true) {\n\t\t\tif (b >= '0' && b <= '9') {\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t} else {\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tprivate long nl() {\n\t\tlong num = 0;\n\t\tint b;\n\t\tboolean minus = false;\n\t\twhile ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n\t\t\t;\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\n\t\twhile (true) {\n\t\t\tif (b >= '0' && b <= '9') {\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t} else {\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tprivate static void tr(Object... o) {\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/microsoft/CalculateCombinations.java",
    "content": "/**\nMicrosoft coding test for SDET\ncalculate Nck for given n & k\n * \n */\npackage com.javaaid.ip.microsoft;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class CalculateCombinations {\n\n\tstatic long calculateCombinations(int n, int k) {\n\t\tint cache[] = new int[k + 1];\n\t\tcache[0] = 1;\n\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tint tmp=Math.min(i, k);\n\t\t\tfor (int j = tmp; j > 0; j--)\n\t\t\t\tcache[j] = cache[j] + cache[j - 1];\n\t\t}\n\t\treturn cache[k];\n\t}\n\n\t/* Driver program to test above function */\n\tpublic static void main(String[] args) {\n\t\tint n = 100, k = 2;\n\t\tSystem.out.printf(\"Value of C(%d, %d) is %d \", n, k, calculateCombinations(n, k));\n\t}\n}"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/spraoi/CoinChange.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.spraoi;\n\nimport java.util.Arrays;\nimport java.util.List;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class CoinChange {\n\tpublic static void main(String[] args) {\n\t    Integer actual = CoinChange.countChange(4,Arrays.asList(1,2));\n\t    System.out.println(actual);\n\t}\n\t public static Integer countChange( Integer money,List<Integer> coins ) {\n\t\t int noOfcoins=coins.size();\n\t\treturn countNumberOfWays(coins,noOfcoins,money);\n\t  }\n\t/**\n\t * @param coins\n\t * @param noOfcoins\n\t * @param money\n\t * @return\n\t */\n\tprivate static Integer countNumberOfWays(List<Integer> coins, int noOfcoins, Integer money) {\n\t\tif(money==0)return 1;\n\t\tif(money<0)return 0;\n\t\tif(noOfcoins<=0 && money>=1)return 0;\n\t\treturn countNumberOfWays(coins,noOfcoins-1,money)+countNumberOfWays(coins,noOfcoins,money-coins.get(noOfcoins-1));\n\t}\n\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/spraoi/IntegerToRomanNumberConversion.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.spraoi;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class IntegerToRomanNumberConversion {\n\tpublic String convertIntToRoman(int num){   \n\t     String m[] = {\"\", \"M\", \"MM\", \"MMM\"};\n\t     String c[] = {\"\", \"C\", \"CC\", \"CCC\", \"CD\", \"D\",  \"DC\", \"DCC\", \"DCCC\", \"CM\"};\n\t     String x[] = {\"\", \"X\", \"XX\", \"XXX\", \"XL\", \"L\",  \"LX\", \"LXX\", \"LXXX\", \"XC\"};\n\t     String i[] = {\"\", \"I\", \"II\", \"III\", \"IV\", \"V\",   \"VI\", \"VII\", \"VIII\", \"IX\"};\n\t         \n\t     String thousands = m[num/1000];\n\t     String hundereds = c[(num%1000)/100];\n\t     String tens =  x[(num%100)/10];\n\t     String ones = i[num%10];\n\t         \n\t     String ans = thousands + hundereds + tens + ones;\n\t     return ans;\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/temnos/RajuMarriage.java",
    "content": "/**\n *Problem statement-\n *--------------------------------\n *Raju and marriage ceremony (100 Marks)\nRaju is attending a marriage ceremony. There are lot of people who are coming and going from the gate. Raju is standing near the gate and observing everything. There are\nN persons and for each person Raju knows A and B which is the time interval in seconds [A , B ] in which a person is present at the gate. Now Raju wants to answer 2\nqueries:\nQuery 1: The maximum number of people which can be present at the gate at any point of time.\nQuery 2: The maximum time at which there are exactly P people standing at the gate.\nNote: If there is no such time for Query 2 then output -1 for the query.\nInput Format\nFirst line of input contains an Integer N i.e. the number of rows.\nSecond line of input contains Integer 2 i.e. the number of columns.\nNext N lines of input containing two space separated integers A and B .\nNext line contains an Integer P.\nConstraints\n1 <= N <= 100000\n1 <= A <= B <= 10\n1 <= P <= 100000\nOutput Format\n2 space separated integer denoting answer to the Query1 and Query2 respectively.\nSample TestCase 1\nInput\n5\n2\n1 4\n3 5\n3 8\n5 9\n4 10\n3\nOutput\n4 8\nExplanation\nQuery 1: The maximum number of people which can be present at the gate at any point of time.\n1 2 3 4\n3 4 5\n3 4 5 6 7 8\n5 6 7 8 9\n4 5 6 7 8 9 10\nHere, in this case at point of time 4 and 5 - we have maximum 4 people. Hence, answer for Query 1 is 4.\nQuery 2: The maximum time at which there are exactly P people standing at the gate.\n1 2 3 4\n3 4 5\n3 4 5 6 7 8\n5 6 7 8 9\n4 5 6 7 8 9 10\nHere, P=3, So, 8 will be maximum common time for 3 people standing at the gate at one time.\n */\n\npackage com.javaaid.ip.temnos;\n\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class RajuMarriage {\n\tpublic static void main(String args[]) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint maxNoOfGuest = Integer.MIN_VALUE;\n\t\tint maxTime = -1;\n\t\tint N = sc.nextInt();\n\t\tsc.nextInt();\n\t\tint a[] = new int[1000001];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfillArray(a, sc.nextInt(), sc.nextInt());\n\t\t}\n\t\tint P = sc.nextInt();\n\t\tfor (int i = 1; i <=1000000 ; i++) {\n\t\t\tif (a[i]!=0 &&a[i] > maxNoOfGuest) {\n\t\t\t\tmaxNoOfGuest = a[i];\n\t\t\t}\n\t\t\tif ( a[i] == P) {\n\t\t\t\tmaxTime = i;\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(maxNoOfGuest);\n\t\tSystem.out.println(maxTime);\n\t\tsc.close();\n\t}\n\n\t/**\n\t * @param nextInt\n\t * @param nextInt2\n\t */\n\tprivate static void fillArray(int a[], int start, int end) {\n\t\tfor (int i = start; i <= end; i++) {\n\t\t\ta[i]++;\n\t\t}\n\n\t}\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/wissen_infotech/SpecialArrayConversion.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.wissen_infotech;\n\nimport java.util.Arrays;\nimport java.util.Scanner;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\npublic class SpecialArrayConversion {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint inputArray[] = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tinputArray[i] = sc.nextInt();\n\t\t}\n\t\tconvertArray(inputArray);\n\t\tprintArray(inputArray);\n\t\tsc.close();\n\t}\n\n\t/**\n\t * @param inputArray\n\t */\n\tprivate static void convertArray(int[] inputArray) {\n\t\tint size = inputArray.length;\n\t\tint primeArray[] = new int[size];\n\t\tint nonPrimeArray[] = new int[size];\n\t\tint primeIndex = 0, nonPrimeIndex = 0, primeCount = 0, k = 0;\n\n\t\tfor (int i = 0; i < inputArray.length; i++) {\n\t\t\tint num = inputArray[i];\n\t\t\tif (checkForPrime(num)) {\n\t\t\t\tprimeArray[primeIndex++] = num;\n\t\t\t\tprimeCount++;\n\t\t\t} else {\n\t\t\t\tnonPrimeArray[nonPrimeIndex++] = num;\n\t\t\t}\n\t\t}\n\t\tArrays.sort(primeArray);\n\t\tArrays.sort(nonPrimeArray);\n\t\tint index = primeArray.length - primeCount;\n\t\tfor (; index < primeArray.length; index++) {\n\t\t\tif (primeArray[index] != 0) {\n\t\t\t\tinputArray[k++] = primeArray[index];\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\t\tfor (int i = nonPrimeArray.length - 1; i >= primeCount; i--) {\n\t\t\tif (nonPrimeArray[i] != 0) {\n\t\t\t\tinputArray[k++] = nonPrimeArray[i];\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\t}\n\n\t/**\n\t * @param num\n\t * @return\n\t */\n\tprivate static boolean checkForPrime(int num) {\n\t\tfor(int i=2;2*i<num;i++) {\n\t        if(num%i==0)\n\t            return false;\n\t    }\n\t    return true;\n\t}\n\n\t/**\n\t * @param inputArray\n\t */\n\tprivate static void printArray(int[] inputArray) {\n\t\tfor (int i = 0; i < inputArray.length; i++) {\n\t\t\tSystem.out.print(inputArray[i] + \" \");\n\t\t}\n\n\t}\n\n}\n"
  },
  {
    "path": "InterviewsPreparation/src/main/java/com/javaaid/ip/wissen_infotech/Stats.java",
    "content": "/**\n * \n */\npackage com.javaaid.ip.wissen_infotech;\n\nimport java.util.ArrayList;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.TreeSet;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.TimeUnit;\n\n/**\n * @author Kanahaiya Gupta\n *\n */\n\npublic class Stats {\n\tpublic static class StatisticsAggregatorImpl implements StatisticsAggregator {\n\t\tConcurrentHashMap<String, ArrayList<Double>> map=new ConcurrentHashMap<String,ArrayList<Double>>();\n\t\tArrayList list=null;\n\t\tvolatile int  count=0;\n\t\t@Override\n\t\tpublic synchronized  void  putNewPrice(String symbol, double price) {\n\t\t\t// YOUR CODE HERE\n\t\t\tif(map.containsKey(symbol)) {\n\t\t\t\t list=map.get(symbol);\n\t\t\t}else {\n\t\t\t\tlist=new ArrayList<Double>();\n\t\t\t}\n\t\t\t list.add(price);\n\t\t\t map.put(symbol, list);\n\n\t\t}\n\n\t\t@Override\n\t\tpublic synchronized  double getAveragePrice(String symbol) {\n\t\t\tArrayList<Double> tmp=map.get(symbol);\n\t\t\t count=tmp.size();\n\t\t\tDouble price=0.0;\n\t\t\tfor(Double d:map.get(symbol)) {\n\t\t\t\tprice+=d;\n\t\t\t}\n\t\t\treturn price/count;\n\t\t\t// YOUR CODE HERE\n\t\t}\n\n\t\t@Override\n\t\tpublic synchronized  int   getTickCount(String symbol) {\n\t\t\treturn count;\n\t\t\t// YOUR CODE HERE\n\t\t}\n\t}\n\n\t////////////////// DO NOT MODIFY BELOW THIS LINE ///////////////////\n\n\tpublic interface StatisticsAggregator {\n\t\t// This is an input. Make note of this price.\n\t\tpublic void putNewPrice(String symbol, double price);\n\n\t\t// Get the average price\n\t\tpublic double getAveragePrice(String symbol);\n\n\t\t// Get the total number of prices recorded\n\t\tpublic int getTickCount(String symbol);\n\t}\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\twhile (scanner.hasNext()) {\n\t\t\tfinal StatisticsAggregator stats = new StatisticsAggregatorImpl();\n\t\t\tfinal Set<String> symbols = new TreeSet<>();\n\n\t\t\tString line = scanner.nextLine();\n\t\t\tString[] inputs = line.split(\",\");\n\t\t\tint threads = Integer.parseInt(inputs[0]);\n\t\t\tExecutorService pool = Executors.newFixedThreadPool(threads);\n\t\t\tfor (int i = 1; i < inputs.length; ++i) {\n\t\t\t\tString[] tokens = inputs[i].split(\" \");\n\t\t\t\tfinal String symbol = tokens[0];\n\t\t\t\tsymbols.add(symbol);\n\t\t\t\tfinal double price = Double.parseDouble(tokens[1]);\n\t\t\t\tpool.submit(new Runnable() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tstats.putNewPrice(symbol, price);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t}\n\t\t\tpool.shutdown();\n\t\t\ttry {\n\t\t\t\tpool.awaitTermination(5000, TimeUnit.MILLISECONDS);\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\n\t\t\tfor (String symbol : symbols) {\n\t\t\t\tSystem.out.println(\n\t\t\t\t\t\tString.format(\"%s %.4f %d\", symbol, stats.getAveragePrice(symbol), stats.getTickCount(symbol)));\n\t\t\t}\n\t\t}\n\t\tscanner.close();\n\n\t}\n}"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n    <a href=\"https://www.facebook.com/groups/codingip/\">\n        <img height=85 src=\"https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/resources/images/javaAidBanner.png\">\n    </a>\n    <br>For more, join our facebook group \"Coding Interview Preparation\" by clicking on above image\n  <br>\n  <br>\n</p>\n\n\n\n# Interviews-Preparation\n  This repository contains coding assessments and their solutions for various IT companies\n\n\n\n|   \t\tCompany Name  \t\t\t |       Problem Statement                                        \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t|                                                                                                     Solution                                                                                                                                                 |\n|:----------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n|           App Dynamics\t\t\t | [Anagram Difference](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/App%20Dynamics/AppDynamics%20Java%20Developer%20Hiring%20Test.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/AnagramDifference.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|           App Dynamics\t\t\t | [Problem] \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/Solution1.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|           App Dynamics\t\t\t | [Problem]\t \t           \t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/MeetingScheduler.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|           App Dynamics\t\t\t | [Problem]\t \t           \t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/app_dynamics/UniqueWordFinder.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|         CA Technologies\t\t\t | [The Light Store](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/CA%20Technologies/CA_Technologies.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/ca/TheLightStore.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|            Cleartrip\t\t\t     | [Strings Chains](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Cleartrip/cleartrip_hackerrank_test.docx)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t  \t\t\t\t\t\t\t\t   \t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/cleartrip/StringChain.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t   |\n|          Goldman Sachs\t\t\t | [Number Checker](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Goldman%20Sachs/GS%20Online%20Assessment%201_2017.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/goldman_sachs/NumberChecker.java)                           \t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t   |\n|          Goldman Sachs\t\t\t | [Number Patterns & finding the possible smallest numeric value](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Goldman%20Sachs/GS%20Online%20Assessment%202_2017.pdf)        \t\t\t\t\t\t\t\t\t\t    \t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/goldman_sachs/MNStringSolution.java)                        \t\t\t\t\t\t\t\t\t\t\t\t      \t\t   |\n|          Goldman Sachs\t\t\t | [Non repeating digit in product](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Goldman%20Sachs/GS%20Online%20Assessment%201_2018.pdf)            \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/goldman_sachs/NonRepeatingDigitInProduct.java)              \t\t\t\t\t\t\t\t\t\t\t\t               |\n|          Goldman Sachs\t\t\t | [Trucker's profit](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Goldman%20Sachs/GS%20Online%20Assessment%202_2018.pdf)            \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| [Solution.java]                  \t\t\t\t\t\t\t  \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|         \t LensKart\t\t\t\t | [String Game](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/LensKart/Lenskart_Hiring_Challenge1.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t   \t\t\t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/lenskart/StringGame.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \t   |\n|         \t LensKart\t\t\t\t | [Max Power](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/LensKart/Lenskart_Hiring_Challenge2.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t   \t\t\t\t\t\t\t\t\t\t\t\t\t| \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \t   \t\t   |\n|         \t LensKart\t\t\t\t | [Thief and Warehouses](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/LensKart/Lenskart_Hiring_Challenge3.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t   \t\t\t\t\t\t\t\t\t\t| \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \t           |\n|         \t MicroSoft\t\t\t\t | [Calculate Nck] \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t   \t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/microsoft/CalculateCombinations.java)\t\t\t\t\t\t\t\t\t\t\t\t\t  \t           \t\t\t\t\t   |\n|         Wissen Infotech\t\t\t | [Special Array Conversion](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Wissen%20Infotech/Wissen_SpecialArrayConversion_problem.jpg)           \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t    | [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/wissen_infotech/SpecialArrayConversion.java)                \t\t\t\t\t\t\t\t\t\t\t\t       \t\t   |\n|         Wissen Infotech\t\t\t | [Stats](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Wissen%20Infotech/WissenCodingProblem2_stats.png)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t   \t\t\t\t\t\t\t\t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/wissen_infotech/Stats.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t       |\n|         Wissen Infotech\t\t\t | [Balance the log](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Wissen%20Infotech/Wissen_technical_screening_2017.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t  \t\t\t\t\t\t\t\t|              \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t      \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|         Wissen Infotech\t\t\t | [Manager names](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Wissen%20Infotech/Wissen_technical_screening_2017_sql.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t\t\t\t  \t\t\t\t|              \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t       |\n|         Wissen Infotech\t\t\t | [Managers](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Wissen%20Infotech/Wissen_technical_screening_2017_sql2.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t  \t\t\t\t\t\t\t\t|              \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t        \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   |\n|             Spraoi\t\t\t     | [Coin Change problem](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Sproai/spraoi_Q1.docx)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t  \t\t\t\t\t\t\t   \t\t\t\t\t\t\t    | [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/spraoi/CoinChange.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t  \t   |\n|             Spraoi\t\t\t     | [Integer to Roman Number Conversion](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Sproai/spraoi_Q2.docx)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t  \t\t\t\t\t\t\t   \t\t\t\t| [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/spraoi/IntegerToRomanNumberConversion.java)                 \t\t\t\t\t\t\t\t\t\t\t\t      \t\t   |\n|             Temnos\t\t\t     | [Raju and marriage ceremony](https://github.com/Java-aid/Interview-Preparations/blob/master/ProblemStatements/Temnos/Coding%20Test_Techgig_Temnos.pdf)           \t\t\t\t\t\t\t\t\t\t\t\t  \t\t\t  \t\t\t\t\t\t\t    | [Solution.java](https://github.com/Java-aid/Interview-Preparations/blob/master/InterviewsPreparation/src/main/java/com/javaaid/ip/temnos/RajuMarriage.java)                       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t       |\n"
  }
]