├── Milestone -2 Day 6-10 [ Amazon ] ├── Q10_NutsAndBoltsProblem.java ├── Q12_ColumnNameFromGivenColumnNumber.java ├── Q8_CountWaysToNthStair.java ├── Q3_IPL2021MatchDay2.java ├── Q15_DeleteNNodesAfterMNodesOfLinkedList.java ├── Q1_MaximumProfit.java ├── Q7_FirstNon-RepeatingCharacterInAStream.java ├── Q2_LongestMountainInArray.java ├── Q11_SerializeAndDeserializeBinaryTree.java ├── Q4_BracketsMatrixChainMultiplication.java ├── Q5_PhoneDirectory.java ├── Q14_BurningTree.java ├── Q9_IsValidSudoku.java ├── Q13_RottingOranges.java └── Q6_MaximumOfAllSubarraysOfSizeK.java ├── Milestone -1 Day 1-5 [ Goldman Sachs] ├── Q12_SquaresInNNChessboard.java ├── Q7_DistributeToyInCircle.java ├── Q3_CountSubArrayProductLessThanK.java ├── Q11_FindMissingAndRepeating.java ├── Q2_OverlappingRectangles.java ├── Q9_NumberFollowingAPattern.java ├── Q6_GreatestCommonDivisorOfStrings.java ├── Q4_RunLengthEncoding.java ├── Q1_PrintAnagramsTogether.java ├── Q15_ArrayPairSumDivisibilityProblem.java ├── Q14_MinimumSizeSubarraySum.java ├── Q8_TotalDecodingMessages.java ├── Q5_UglyNumbers.java ├── Q10_FindMax10NumbersInListHaving10Mentries.java └── Q13_DecodeTheString.java ├── Milestone -3 Day 11-15 [ Microsoft ] ├── Q14_MinimumStepsToDestination.java ├── Q10_SticklerThief.java ├── Q11_GenerateBinaryNumbers.java ├── Q3_RotateBy90Degree.java ├── Q9_CountNumberOfSubTreesHavingGivenSum.java ├── Q1_MinimumSumPartition.java ├── Q4_SpirallyTraversingMatrix.java ├── Q5_StockSpanProblem.java ├── Q2_PrerequisiteTasks.java ├── Q12_FindAllFourSumNumbers.java ├── Q8_ConnectNodesAtSameLevel.java ├── Q13_BridgeEdgeInGraph.java ├── Q15_AlienDictionary.java ├── Q6_PossibleWordsFromPhoneDigits.java └── Q7_UnitAreaOfLargestRegionOf1s.java └── README.md /Milestone -2 Day 6-10 [ Amazon ]/Q10_NutsAndBoltsProblem.java: -------------------------------------------------------------------------------- 1 | class Q10_NutsAndBoltsProblem{ 2 | void matchPairs(char nuts[], char bolts[], int n) { 3 | Arrays.sort(nuts); 4 | Arrays.sort(bolts); 5 | } 6 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q12_SquaresInNNChessboard.java: -------------------------------------------------------------------------------- 1 | class Q_SquaresInNNChessboard{ 2 | static Long squaresInChessBoard(Long N) { 3 | if(N==1) return 1L; 4 | return (N*N)+squaresInChessBoard(N-1); 5 | //return (n*(n+1)*((2*n)+1))/6; 6 | } 7 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q14_MinimumStepsToDestination.java: -------------------------------------------------------------------------------- 1 | class 2 | { 3 | static int minSteps(int D){ 4 | int target = Math.abs(D), sum = 0, step = 0; 5 | 6 | while(sum < target || (sum-target)%2 != 0) 7 | { 8 | step++; 9 | sum += step; 10 | } 11 | return step; 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q7_DistributeToyInCircle.java: -------------------------------------------------------------------------------- 1 | public class Q7_DistributeToyInCircle{ 2 | public int solve(int A, int B, int C) { 3 | return (A+C-1)%B; 4 | } 5 | public static void main(String arg[]){ 6 | int n = 5; 7 | int m = 8; 8 | int k = 2; 9 | System.out.print(lastPosition(n, m, k)); 10 | } 11 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q3_CountSubArrayProductLessThanK.java: -------------------------------------------------------------------------------- 1 | public class Q3_CountSubArrayProductLessThanK{ 2 | public int countSubArrayProductLessThanK(long a[], long n, long k) 3 | { 4 | int j=0,ans=0; 5 | long p=1; 6 | for(int i=0;i=k){ 9 | p/=a[j]; 10 | j++; 11 | } 12 | ans+=(i-j+1); 13 | } 14 | return ans; 15 | } 16 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q11_FindMissingAndRepeating.java: -------------------------------------------------------------------------------- 1 | class Q11_FindMissingAndRepeating{ 2 | int[] findTwoElement(int arr[], int n) { 3 | int i=0; 4 | int b[]=new int[n+1]; 5 | int c[]=new int[2]; 6 | while(i<=n-1){ 7 | b[arr[i]]++; 8 | i++; 9 | } 10 | for(int j=1;j<=n; j++){ 11 | if(b[j]==2) 12 | c[0]=j; 13 | if(b[j]==0) 14 | c[1]=j; 15 | } 16 | return c; 17 | } 18 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q12_ColumnNameFromGivenColumnNumber.java: -------------------------------------------------------------------------------- 1 | class Q12_ColumnNameFromGivenColumnNumber{ 2 | String colName (long n){ 3 | StringBuffer sb=new StringBuffer(); 4 | while(n>0){ 5 | sb.append(charOf(n%26)); 6 | n=(n-1)/26; 7 | } 8 | sb.reverse(); 9 | return(sb.toString()); 10 | } 11 | public char charOf(long val){ 12 | if(val==0) 13 | return('Z'); 14 | else 15 | return((char)(64+val)); 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q10_SticklerThief.java: -------------------------------------------------------------------------------- 1 | class Q10_SticklerThief{ 2 | public int FindMaxSum(int arr[], int n) 3 | { 4 | Integer[] dp=new Integer[n+1]; 5 | return maxloot(arr,0,dp); 6 | } 7 | int maxloot(int[] arr,int index,Integer[] dp){ 8 | 9 | if(index>=arr.length) 10 | return 0; 11 | if(dp[index]!=null) 12 | return dp[index]; 13 | int a1=arr[index]+maxloot(arr,index+2,dp); 14 | int a2=maxloot(arr,index+1,dp); 15 | return dp[index]=Math.max(a1,a2); 16 | } 17 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q2_OverlappingRectangles.java: -------------------------------------------------------------------------------- 1 | public class OverlappingRectangles_Q2{ 2 | 3 | static int doOverlap(int L1[], int R1[], int L2[], int R2[]) { 4 | if(L1[0]>R2[0] || L2[0]>R1[0]) 5 | return 0; 6 | if(R1[1]>L2[1] || R2[1]>L1[1]) 7 | return 0; 8 | return 1; 9 | } 10 | 11 | public static void main(String[] args) { 12 | int[] L1={0,10}; 13 | int[] R1={10,0}; 14 | int[] L2={5,5}; 15 | int[] r2={15,0}; 16 | System.out.println(doOverlap(L1, R1, L2, R2)); 17 | } 18 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q9_NumberFollowingAPattern.java: -------------------------------------------------------------------------------- 1 | class Q9_NumberFollowingAPattern{ 2 | static String printMinNumberForPattern(String S){ 3 | Stack st=new Stack<>(); 4 | String ss=""; 5 | for(int i=0;i<=S.length();i++) 6 | { 7 | st.push(i+1); 8 | if(i==S.length() || S.charAt(i)=='I') 9 | { 10 | while(st.size()>0) 11 | { 12 | ss+=String.valueOf(st.pop()); 13 | } 14 | } 15 | } 16 | return ss; 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q11_GenerateBinaryNumbers.java: -------------------------------------------------------------------------------- 1 | class Q11_GenerateBinaryNumbers{ 2 | static ArrayList generate(int n) 3 | { 4 | ArrayList res = new ArrayList<>(); 5 | Queue q = new ArrayDeque<>(); 6 | q.add("1"); 7 | int count = 0; 8 | 9 | while(q.size() > 0){ 10 | String rem = q.remove(); 11 | res.add(rem); 12 | count++; 13 | if(count == n) return res; 14 | q.add(rem + "0"); 15 | q.add(rem + "1"); 16 | } 17 | return res; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q8_CountWaysToNthStair.java: -------------------------------------------------------------------------------- 1 | class Q8_CountWaysToNthStair{ 2 | 3 | //---> Solution one for this question if order doesn't matter 4 | /* 5 | Long countWays(int m){ 6 | 7 | return (long)(m/2)+1; 8 | } 9 | */ 10 | 11 | //---> Solution two Using DP 12 | Long countWays(int m){ 13 | Long res[] = new Long[m+1]; 14 | res[0] = 1L; 15 | res[1] = 1L; 16 | for (int i = 2; i <= m; i++) 17 | res[i] = (res[i-2] + 1); //--> No. of ways to reach i will be ways to reach (i - 2) + 1 18 | 19 | return res[m]; 20 | } 21 | 22 | 23 | 24 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q3_RotateBy90Degree.java: -------------------------------------------------------------------------------- 1 | class Q3_RotateBy90Degree{ 2 | static void rotate(int matrix[][]) 3 | { 4 | int n = matrix.length; 5 | int t = 0; 6 | 7 | for (int r = 0; r < n; ++r) 8 | { 9 | for (int c = r; c < n - r - 1; ++c) 10 | { 11 | t = matrix[r][c]; 12 | matrix[r][c] = matrix[c][n - 1 - r]; 13 | matrix[c][n - 1 - r] = matrix[n - 1 - r][n - 1 - c]; 14 | matrix[n - 1 - r][n - 1 - c] = matrix[n - 1 - c][r]; 15 | matrix[n - 1 - c][r] = t; 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q9_CountNumberOfSubTreesHavingGivenSum.java: -------------------------------------------------------------------------------- 1 | class Q9_CountNumberOfSubTreesHavingGivenSum{ 2 | int count; 3 | private int subTreeSum(Node root, int X){ 4 | if(root==null) return 0; 5 | int sum = root.data + subTreeSum(root.left, X) + subTreeSum(root.right, X); 6 | if(sum==X) count++; 7 | return sum; 8 | } 9 | 10 | //Function to count number of subtrees having sum equal to given sum. 11 | int countSubtreesWithSumX(Node root, int X) 12 | { 13 | //Add your code here. 14 | count = 0; 15 | subTreeSum(root, X); 16 | return count; 17 | } 18 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q3_IPL2021MatchDay2.java: -------------------------------------------------------------------------------- 1 | class Q3_IPL2021MatchDay2{ 2 | static ArrayList max_of_subarrays(int arr[], int n, int k) { 3 | ArrayList ans=new ArrayList<>(); 4 | Deque dq=new ArrayDeque<>(); 5 | for(int i=0;i=k-1){ 14 | ans.add(arr[dq.getFirst()]); 15 | } 16 | 17 | } 18 | return ans; 19 | } 20 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q1_MinimumSumPartition.java: -------------------------------------------------------------------------------- 1 | class Q1_MinimumSumPartition{ 2 | public int minDifference(int arr[], int n) 3 | { 4 | int sum=0; 5 | for(int a:arr) 6 | sum+=a; 7 | Integer[][] dp=new Integer[n][sum+1]; 8 | return subSetDiff(dp,arr,0,0,0); 9 | } 10 | static int subSetDiff(Integer[][] dp,int[] arr,int curr,int s1,int s2){ 11 | if(curr==arr.length) 12 | return Math.abs(s1-s2); 13 | if(dp[curr][s1]==null){ 14 | dp[curr][s1]= Math.min( subSetDiff(dp,arr,curr+1,s1+arr[curr],s2), subSetDiff(dp,arr,curr+1,s1,s2+arr[curr]) ); 15 | } 16 | return dp[curr][s1]; 17 | } 18 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q6_GreatestCommonDivisorOfStrings.java: -------------------------------------------------------------------------------- 1 | class Q6_GreatestCommonDivisorOfStrings{ 2 | public String gcdOfStrings(String str1, String str2) { 3 | if(!(str1 + str2).equals(str2 + str1)){ 4 | return ""; 5 | } 6 | 7 | else if(str1.equals(str2)){ 8 | return str1; 9 | } 10 | 11 | else if(str1.length() > str2.length()){ 12 | // remove str2 from str1 13 | return gcdOfStrings(str1.substring(str2.length()) , str2); 14 | } 15 | else{ 16 | // remove str1 from str2 17 | return gcdOfStrings(str2.substring(str1.length()) , str1); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q15_DeleteNNodesAfterMNodesOfLinkedList.java: -------------------------------------------------------------------------------- 1 | class Q15_DeleteNNodesAfterMNodesOfLinkedList{ 2 | static void linkdelete(Node head, int M, int N) 3 | { 4 | Node temp=head; 5 | int n=1,m=N; 6 | while(temp!=null){ 7 | if(n==M){ 8 | Node p=temp; 9 | while(p!=null && m-->0){ 10 | p=p.next; 11 | } 12 | if(p!=null) 13 | temp.next=p.next; 14 | else 15 | temp.next=p; 16 | n=0; 17 | m=N; 18 | } 19 | n++; 20 | temp=temp.next; 21 | } 22 | } 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q1_MaximumProfit.java: -------------------------------------------------------------------------------- 1 | class Q1_MaximumProfit{ 2 | static int maxProfit(int k, int n, int A[]) { 3 | int profit[][] = new int[k + 1][ n + 1]; 4 | for (int i = 0; i <= k; i++) 5 | profit[i][0] = 0; 6 | for (int j = 0; j <= n; j++) 7 | profit[0][j] = 0; 8 | for (int i = 1; i <= k; i++) 9 | { 10 | int prevDiff = Integer.MIN_VALUE; 11 | for (int j = 1; j < n; j++) 12 | { 13 | prevDiff = Math.max(prevDiff,profit[i - 1][j - 1] - A[j - 1]); 14 | profit[i][j] = Math.max(profit[i][j - 1],A[j] + prevDiff); 15 | } 16 | } 17 | 18 | return profit[k][n - 1]; 19 | } 20 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q7_FirstNon-RepeatingCharacterInAStream.java: -------------------------------------------------------------------------------- 1 | class Q7_FirstNon-RepeatingCharacterInAStream{ 2 | public String FirstNonRepeating(String A) 3 | { 4 | StringBuilder sb=new StringBuilder(); 5 | int isRepet[]=new int[26]; 6 | Deque queue=new ArrayDeque<>(); 7 | for(int i=0;i nums[idx] ? 1: 0; 15 | 16 | if (up != 0 && down != 0) { 17 | longest = Math.max(longest, up + down + 1); 18 | } 19 | } 20 | return longest; 21 | } 22 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q4_RunLengthEncoding.java: -------------------------------------------------------------------------------- 1 | public class RunLengthEncoding_Q4{ 2 | static String encode(String str){ 3 | String res=""; 4 | int count=1; 5 | int n=str.length(); 6 | if(n==0) 7 | return res; 8 | for(int i=1;i ans=new ArrayList<>(); 3 | int k=0,l=0; 4 | int i; 5 | while(k=l;i--){ 17 | ans.add( arr[m-1][i]); 18 | // num++; 19 | } 20 | m--; 21 | } 22 | if(l=k;i--){ 24 | ans.add( arr[i][l]); 25 | //num++; 26 | } 27 | l++; 28 | } 29 | } 30 | return ans; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q1_PrintAnagramsTogether.java: -------------------------------------------------------------------------------- 1 | public class Q1_PrintAnagramsTogether{ 2 | public List> Anagrams(String[] string_list) { 3 | List> res=new ArrayList<>(); 4 | HashMap> hm=new HashMap<>(); 5 | for(String s:string_list){ 6 | char[] ch=s.toCharArray(); 7 | Arrays.sort(ch); 8 | String key=Arrays.toString(ch); 9 | if(hm.containsKey(key)){ 10 | hm.get(key).add(s); 11 | }else{ 12 | List l=new ArrayList(); 13 | l.add(s); 14 | hm.put(key,l); 15 | } 16 | } 17 | for(String s:hm.keySet()){ 18 | res.add(hm.get(s));; 19 | } 20 | return res; 21 | } 22 | public static void main(String[] args) { 23 | String[] words[] = {act,god,cat,dog,tac}; 24 | List> res=Anagrams(words); 25 | } 26 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q15_ArrayPairSumDivisibilityProblem.java: -------------------------------------------------------------------------------- 1 | class Q15_ArrayPairSumDivisibilityProblem{ 2 | public boolean canPair(int ar[], int k) { 3 | if (ar.length % 2 == 1) return false; 4 | HashMap hm = new HashMap<>(); 5 | for (int i = 0; i < ar.length; i++) { 6 | int rem = ((ar[i] % k) + k) % k; 7 | if (!hm.containsKey(rem)) { 8 | hm.put(rem, 0); 9 | } 10 | hm.put(rem, hm.get(rem) + 1); 11 | } 12 | for (int i = 0; i < ar.length; i++) { 13 | 14 | int rem = ((ar[i] % k) + k) % k; 15 | if (2 * rem == k) { 16 | if (hm.get(rem) % 2 == 1) return false; 17 | }else if (rem == 0) { 18 | if (hm.get(rem) % 2 == 1) return false; 19 | }else { 20 | if (hm.get(k - rem) != hm.get(rem)) return false; 21 | } 22 | } 23 | return true; 24 | } 25 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q14_MinimumSizeSubarraySum.java: -------------------------------------------------------------------------------- 1 | class Q14_MinimumSizeSubarraySum{ 2 | public int minSubArrayLen(int target, int[] nums) { 3 | int i =0 , j = 0; 4 | int n = nums.length; 5 | int min = Integer.MAX_VALUE; 6 | int currSum = 0; 7 | 8 | while(j < n){ 9 | if(j < n && currSum >= target){ 10 | currSum += nums[j++]; 11 | } 12 | 13 | while(j < n && currSum < target){ 14 | currSum += nums[j++]; 15 | } 16 | 17 | if(currSum >= target){ 18 | 19 | while(i< j && currSum - nums[i] >= target){ 20 | currSum -= nums[i++]; 21 | } 22 | 23 | min = Math.min(min , j- i); 24 | } 25 | 26 | 27 | } 28 | 29 | if(min == Integer.MAX_VALUE) return 0; 30 | 31 | return min ; 32 | 33 | } 34 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q8_TotalDecodingMessages.java: -------------------------------------------------------------------------------- 1 | public class Q8_TotalDecodingMessages{ 2 | 3 | static long mod = 1000000007; 4 | public int CountWays(String str) 5 | { 6 | char[] digit=str.toCharArray(); 7 | int n=digit.length; 8 | Long [] dp=new Long[n+1]; 9 | if(n==0 || n==1 && digit[0]=='0'){ 10 | return 0; 11 | } 12 | return countDecoding(digit,n,dp); 13 | } 14 | static int countDecoding(char[] digit,int n,Long[] dp){ 15 | if(n==0 || n==1){ 16 | return 1; 17 | } 18 | if(digit[0]=='0'){ 19 | return 0; 20 | } 21 | long count=0; 22 | if(dp[n]!=null) 23 | return dp[n].intValue(); 24 | if(digit[n-1]>'0'){ 25 | count=countDecoding(digit,n-1,dp); 26 | } 27 | if(digit[n-2]=='1' || (digit[n-2]=='2' && digit[n-1]<'7')){ 28 | count=count%mod+countDecoding(digit,n-2,dp)%mod; 29 | } 30 | return (dp[n]=count%mod).intValue(); 31 | } 32 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q11_SerializeAndDeserializeBinaryTree.java: -------------------------------------------------------------------------------- 1 | /*Complete the given function 2 | Node is as follows: 3 | class Tree{ 4 | int data; 5 | Tree left,right; 6 | Tree(int d){ 7 | data=d; 8 | left=right=null; 9 | } 10 | }*/ 11 | 12 | class Q11_SerializeAndDeserializeBinaryTree{ 13 | //Function to serialize a tree and return a list containing nodes of tree. 14 | public void serialize(Node root, ArrayList arr) 15 | { 16 | if(root==null){ 17 | arr.add(-1); 18 | return; 19 | } 20 | arr.add(root.data); 21 | serialize(root.left,arr); 22 | serialize(root.right,arr); 23 | } 24 | int index=0; 25 | //Function to deserialize a list and construct the tree. 26 | public Node deSerialize(ArrayList arr) 27 | { 28 | if(index==arr.size()) 29 | return null; 30 | int val=arr.get(index); 31 | index++; 32 | if(val==-1){ 33 | return null; 34 | } 35 | Node root=new Node(val); 36 | root.left=deSerialize(arr); 37 | root.right=deSerialize(arr); 38 | return root; 39 | } 40 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q5_StockSpanProblem.java: -------------------------------------------------------------------------------- 1 | class Q5_StockSpanProblem{ 2 | public static int[] calculateSpan(int price[], int n) 3 | { 4 | int S[] = new int[n]; 5 | Stack st=new Stack<>(); 6 | st.push(0); 7 | 8 | //span value of first day is always 1. 9 | S[0]=1; 10 | 11 | for(int i=1;i=price[st.peek()]) 16 | { 17 | st.pop(); 18 | } 19 | 20 | //if stack becomes empty, then price[i] is greater than all 21 | //elements on left of it in list so span is i+1. 22 | //Else price[i] is greater than elements after value at top of stack. 23 | S[i]=st.isEmpty()?i+1:i-st.peek(); 24 | 25 | //pushing this element to stack. 26 | st.push(i); 27 | 28 | } 29 | //returning the list. 30 | return S; 31 | } 32 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q5_UglyNumbers.java: -------------------------------------------------------------------------------- 1 | class Q5_UglyNumbers{ 2 | long getNthUglyNo(int n) { 3 | long ugly[] = new long[n]; // To store ugly numbers 4 | int i2 = 0, i3 = 0, i5 = 0; 5 | long next_multiple_of_2 = 2; 6 | long next_multiple_of_3 = 3; 7 | long next_multiple_of_5 = 5; 8 | long next_ugly_no = 1; 9 | 10 | ugly[0] = 1; 11 | 12 | for (int i = 1; i < n; i++) { 13 | next_ugly_no = 14 | Math.min(next_multiple_of_2,Math.min(next_multiple_of_3, next_multiple_of_5)); 15 | 16 | ugly[i] = next_ugly_no; 17 | if (next_ugly_no == next_multiple_of_2) { 18 | i2 = i2 + 1; 19 | next_multiple_of_2 = ugly[i2] * 2; 20 | } 21 | if (next_ugly_no == next_multiple_of_3) { 22 | i3 = i3 + 1; 23 | next_multiple_of_3 = ugly[i3] * 3; 24 | } 25 | if (next_ugly_no == next_multiple_of_5) { 26 | i5 = i5 + 1; 27 | next_multiple_of_5 = ugly[i5] * 5; 28 | } 29 | } /*End of for loop (i=1; i=0;i--) 14 | heapify(ans,i,10); 15 | for(int i=10;ians[0]) 18 | { 19 | ans[0]=nums[i]; 20 | heapify(ans,0,10); 21 | } 22 | } 23 | System.out.println("Max 10 elements are:\n"); 24 | Arrays.sort(ans); 25 | for(int i=0;i<10;i++) 26 | System.out.println(ans[i]); 27 | } 28 | public static void heapify(int arr[],int i,int n) 29 | { 30 | int large=i; 31 | int l=2*i+1; 32 | int r=2*i+2; 33 | if(l> displayContacts(int n, 3 | String contact[], String str) 4 | { 5 | HashSet set = new HashSet<>(); 6 | for (String ele : contact) { 7 | set.add(ele); 8 | } 9 | contact = new String[set.size()]; 10 | int j = 0; 11 | for (String ele : set) { 12 | contact[j++] = ele; 13 | } 14 | Arrays.sort(contact); 15 | ArrayList> result = new ArrayList<>(); 16 | for (int i = 0; i < str.length(); i++) { 17 | result.add(new ArrayList<>()); 18 | } 19 | 20 | for (String cont : contact) { 21 | for (int i = 0; i < cont.length(); i++) { 22 | if (i < str.length() && str.charAt(i) == cont.charAt(i)) { 23 | result.get(i).add(cont); 24 | } else { 25 | break; 26 | } 27 | } 28 | } 29 | 30 | for (int i = 0; i < str.length(); i++) { 31 | if (result.get(i).size() == 0) { 32 | result.get(i).add("0"); 33 | } 34 | } 35 | 36 | return result; 37 | } 38 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q2_PrerequisiteTasks.java: -------------------------------------------------------------------------------- 1 | class Q2_PrerequisiteTasks{ 2 | public void make_graph(int N ,int [][] prerequisites, ArrayList> graph){ 3 | for(int i=0;i> graph, int node, int[] onpath, int[] visited) { 8 | 9 | if (visited[node]==1) return false; 10 | 11 | onpath[node] = 1; visited[node] = 1; 12 | 13 | for (Integer neigh : graph.get(node)) 14 | if (onpath[neigh] == 1 || dfs_cycle(graph, neigh, onpath, visited) ) 15 | return true; 16 | onpath[node] = 0; 17 | return false; 18 | } 19 | public boolean isPossible(int N, int[][] prerequisites) 20 | { 21 | // Your Code goes here 22 | ArrayList> graph = new ArrayList>(); 23 | for(int i=0;i()); 25 | } 26 | make_graph(N,prerequisites,graph); 27 | int[] vis = new int[N]; 28 | int[] onpath = new int[N]; 29 | 30 | for(int i=0;i path=new ArrayList<>(); 16 | timer=0; 17 | int burntime=0; 18 | rootPath(root,target,path); 19 | for(int i=0;i0?path.get(i-1):null; 22 | BurnTree(node,block,burntime); 23 | burntime++; 24 | } 25 | return timer; 26 | 27 | } 28 | public static void BurnTree(Node node , Node block , int btime){ 29 | 30 | if(node == null) return; 31 | 32 | timer= Math.max(timer , btime); 33 | 34 | if(node.left != block) BurnTree(node.left , block , btime + 1); 35 | if(node.right != block) BurnTree(node.right , block , btime + 1); 36 | 37 | } 38 | public static boolean rootPath(Node node , int target , ArrayList path){ 39 | 40 | if(node == null) return false; 41 | 42 | if(node.data == target){ 43 | path.add(node); 44 | return true; 45 | } 46 | 47 | boolean L = rootPath(node.left , target , path); 48 | boolean R = rootPath(node.right , target , path); 49 | 50 | if( L|| R){ 51 | path.add(node); 52 | return true; 53 | } 54 | 55 | return false; 56 | } 57 | } -------------------------------------------------------------------------------- /Milestone -1 Day 1-5 [ Goldman Sachs]/Q13_DecodeTheString.java: -------------------------------------------------------------------------------- 1 | class Q13_DecodeTheString{ 2 | static String decodedString(String s){ 3 | if(s == "")return ""; 4 | String sol = new String(); 5 | int repeat = 1; 6 | for(int i =0;i st = new Stack<>(); 23 | st.push('['); 24 | int k = i+1; 25 | while(!st.isEmpty()) 26 | { 27 | if(s.charAt(k) == ']') 28 | { 29 | st.pop(); 30 | k++; 31 | } 32 | else if(s.charAt(k) =='[') 33 | { 34 | st.push('['); 35 | k++; 36 | } 37 | else k++; 38 | } 39 | String inside_bracket = decodedString(s.substring(i+1,k-1)); 40 | i = k-1; 41 | for(int j =0;j st = new HashSet<>(); 18 | 19 | for(int row = 0; row < 3; row++){ 20 | for(int col = 0; col < 3; col++){ 21 | int curr = arr[row + startRow][col + startCol]; 22 | if (st.contains(curr)) 23 | return false; 24 | if (curr != 0) 25 | st.add(curr); 26 | } 27 | } 28 | return true; 29 | } 30 | public static boolean notInCol(int arr[][], int col){ 31 | HashSet st = new HashSet<>(); 32 | 33 | for(int i = 0; i < 9; i++){ 34 | if (st.contains(arr[i][col])) 35 | return false; 36 | if (arr[i][col] != 0) 37 | st.add(arr[i][col]); 38 | } 39 | return true; 40 | } 41 | public static boolean notInRow(int arr[][], int row){ 42 | HashSet st = new HashSet<>(); 43 | 44 | for(int i = 0; i < 9; i++){ 45 | if (st.contains(arr[row][i])) 46 | return false; 47 | 48 | if (arr[row][i] != 0) 49 | st.add(arr[row][i]); 50 | } 51 | return true; 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q12_FindAllFourSumNumbers.java: -------------------------------------------------------------------------------- 1 | class Q12_FindAllFourSumNumbers{ 2 | public ArrayList> fourSum(int[] a, int k) { 3 | int n = a.length; 4 | ArrayList> ans = new ArrayList>(); 5 | if (n < 4) return ans; 6 | 7 | Arrays.sort(a); 8 | for (int i = 0; i < n - 3; i++) { 9 | // current element is greater than k then no quadruplet can be found 10 | if (a[i] > 0 && a[i] > k) break; 11 | 12 | // removing duplicates 13 | if (i > 0 && a[i] == a[i - 1]) continue; 14 | 15 | for (int j = i + 1; j < n - 2; ++j) { 16 | // removing duplicates 17 | if (j > i + 1 && a[j] == a[j - 1]) continue; 18 | 19 | // taking two pointers 20 | int left = j + 1; 21 | int right = n - 1; 22 | while (left < right) { 23 | int old_l = left; 24 | int old_r = right; 25 | // calculate current sum 26 | int sum = a[i] + a[j] + a[left] + a[right]; 27 | if (sum == k) { 28 | // add to answer 29 | ans.add(new ArrayList( 30 | Arrays.asList(a[i], a[j], a[left], a[right]))); 31 | 32 | // removing duplicates 33 | while (left < right && a[left] == a[old_l]) left++; 34 | while (left < right && a[right] == a[old_r]) right--; 35 | } else if (sum > k) { 36 | right--; 37 | } else { 38 | left++; 39 | } 40 | } 41 | } 42 | } 43 | return ans; 44 | } 45 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q8_ConnectNodesAtSameLevel.java: -------------------------------------------------------------------------------- 1 | class Q8_ConnectNodesAtSameLevel{ 2 | public void connect(Node root) 3 | { 4 | //creating queue for level order traversal of tree. 5 | Queue q = new LinkedList<>(); 6 | q.add(root); 7 | 8 | //prev holds the value of previous node on the particular level. 9 | Node prev=null; 10 | 11 | //end will hold value of last node of a level 12 | //and nextend will store the same for the next level. 13 | Node end = root; 14 | Node nextend = null; 15 | 16 | while(!q.isEmpty()) 17 | { 18 | //storing the front element of queue in temp and popping it. 19 | Node temp = q.peek(); 20 | q.poll(); 21 | 22 | //storing all available nodes in queue and updating nextend. 23 | if(temp.left!=null) 24 | { 25 | q.add(temp.left); 26 | nextend = temp.left; 27 | } 28 | if(temp.right!=null) 29 | { 30 | q.add(temp.right); 31 | nextend = temp.right; 32 | } 33 | 34 | //setting nextRight of previous node of that level. 35 | if(prev!=null) 36 | prev.nextRight = temp; 37 | 38 | //if we reach the end of a level, we set nextRight of the 39 | //current node and prev to NULL. 40 | if(temp == end) 41 | { 42 | temp.nextRight = null; 43 | prev = null; 44 | //we also set the value of end for next level. 45 | end = nextend; 46 | } 47 | //else we set prev to current node temp. 48 | else 49 | prev = temp; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q13_RottingOranges.java: -------------------------------------------------------------------------------- 1 | class Q13_RottingOranges{ 2 | 3 | public int orangesRotting(int[][] grid) { 4 | List dirs = List.of( 5 | new int[]{0,-1}, 6 | new int[]{0,1}, 7 | new int[]{1,0}, 8 | new int[]{-1,0}); 9 | 10 | var dq = new ArrayDeque(); 11 | int fresh = 0; 12 | 13 | // collect all rottten orange in queue and count fresh orange . 14 | for(int i =0; i=grid.length || y>=grid[0].length) continue; 36 | 37 | if(grid[x][y] == 1){ 38 | grid[x][y] = 2; //rotten the fresh orange 39 | dq.offer(new int[]{x,y}); // new rotten orange will make other rotten 40 | fresh--; // decrease fresh count 41 | } 42 | } 43 | } 44 | //if its not empty mean , it took time to make fresh orange rotten. 45 | if(!dq.isEmpty()) time++; 46 | } 47 | 48 | 49 | return fresh == 0 ? time : -1; 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q13_BridgeEdgeInGraph.java: -------------------------------------------------------------------------------- 1 | class Q13_BridgeEdgeInGraph{ 2 | //Function to perform DFS on graph. 3 | void DFS(ArrayList> adj, int v, boolean visited[]) 4 | { 5 | //marking the current vertex as visited. 6 | visited[v] = true; 7 | 8 | //traversing over the adjacent vertices. 9 | for (int i = 0; i < adj.get(v).size(); ++i) 10 | 11 | //if any vertex is not visited, we call the function 12 | //recursively for adjacent node. 13 | if (!visited[adj.get(v).get(i)]) 14 | DFS(adj, adj.get(v).get(i), visited); 15 | } 16 | 17 | //Function to find whether graph is connected. 18 | boolean isConnected(ArrayList> adj,int V,int one,int two) 19 | { 20 | //using boolean array to mark visited nodes and currently 21 | //marking all the nodes as false. 22 | boolean visited[] = new boolean[V]; 23 | 24 | //finding all reachable vertices from first vertex 25 | //and marking them visited. 26 | DFS(adj, one, visited); 27 | 28 | //if second vertex is not visited, we return false else true. 29 | if (visited[two] == false) 30 | return false; 31 | return true; 32 | } 33 | 34 | //Function to find if the given edge is a bridge in graph. 35 | public int isBridge(int V, ArrayList> adj,int c,int d) 36 | { 37 | //if graph is not connected, we return false. 38 | if (!isConnected(adj, V, c, d)) 39 | return 0; 40 | else 41 | { 42 | //we remove edge from undirected graph. 43 | adj.get(c).remove(new Integer(d)); 44 | adj.get(d).remove(new Integer(c)); 45 | 46 | //if graph is connected, we return false else true. 47 | if (isConnected(adj, V, c, d)) 48 | return 0; 49 | else 50 | return 1; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Milestone -2 Day 6-10 [ Amazon ]/Q6_MaximumOfAllSubarraysOfSizeK.java: -------------------------------------------------------------------------------- 1 | class Q6_MaximumOfAllSubarraysOfSizeK{ 2 | static ArrayList max_of_subarrays(int arr[], int n, int k) 3 | { 4 | ArrayList res = new ArrayList (0); 5 | ArrayDeque dq = new ArrayDeque<>(); 6 | StringBuilder sb = new StringBuilder(); 7 | 8 | int i = 0; 9 | 10 | //iterating over first k elements or first window of array. 11 | for(i = 0; i < k ; i++) 12 | { 13 | //for every element, the previously smaller elements 14 | //are useless so removing them from deque. 15 | while(dq.isEmpty() == false && arr[i] >= arr[dq.peekLast()]) 16 | dq.pollLast(); 17 | 18 | //adding new element at back of deque. 19 | dq.add(i); 20 | } 21 | 22 | //iterating over the rest of the elements. 23 | for(; i < n; i++) 24 | { 25 | //the element at the front of the deque is the largest 26 | //element of previous window, so adding it to the list. 27 | res.add(arr[dq.peek()]); 28 | 29 | //removing the elements which are out of this window. 30 | while(dq.isEmpty() == false && (dq.peekFirst() <= i-k)) 31 | dq.pollFirst(); 32 | 33 | //removing all elements smaller than the element being 34 | //added currently (removing useless elements). 35 | while(dq.isEmpty() == false && (arr[i] >= arr[dq.peekLast()])) 36 | dq.pollLast(); 37 | 38 | //adding new element at back of deque. 39 | dq.add(i); 40 | } 41 | 42 | //the element at the front of the deque is the largest 43 | //element of last window, so adding it to the list. 44 | res.add(arr[dq.peek()]); 45 | dq.pollFirst(); 46 | 47 | //returning the list. 48 | return res; 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q15_AlienDictionary.java: -------------------------------------------------------------------------------- 1 | 2 | class Graph 3 | { 4 | List> adj = new ArrayList<>(); 5 | 6 | Graph(int n) 7 | { 8 | for(int i=0;i()); 11 | } 12 | } 13 | 14 | void addEdge(int from, int to) 15 | { 16 | adj.get(from).add(to); 17 | } 18 | 19 | int getNoOfVertices() 20 | { 21 | return adj.size(); 22 | } 23 | 24 | void topologicalSortUtil(int curr, boolean[] visited, Stack st) 25 | { 26 | visited[curr] = true; 27 | 28 | for (int i= 0;i< adj.get(curr).size();i++) 29 | { 30 | int x = adj.get(curr).get(i); 31 | if(!visited[x]) 32 | { 33 | topologicalSortUtil(x, visited, st); 34 | } 35 | } 36 | 37 | st.push(curr); 38 | } 39 | 40 | public String topologicalSort() 41 | { 42 | Stack st = new Stack<>(); 43 | int n = getNoOfVertices(); 44 | boolean[] visited = new boolean[n]; 45 | for(int i = 0;i < n;i++) 46 | visited[i] = false; 47 | 48 | for(int i = 0;i < n;i++) 49 | if (!visited[i]) 50 | topologicalSortUtil(i, visited, st); 51 | 52 | String ans = ""; 53 | while (!st.isEmpty()) 54 | ans += (char)('a' + st.pop()); 55 | 56 | adj.clear(); 57 | return ans; 58 | 59 | } 60 | 61 | } 62 | 63 | 64 | class Solution 65 | { 66 | public String findOrder(String [] words, int n, int k) 67 | { 68 | Graph g = new Graph(k); 69 | // int n = words.length; 70 | for (int i = 0; i < n - 1; i++) 71 | { 72 | int len = Math.min(words[i].length(), words[i+1].length()); 73 | for(int j = 0;j < len;j++) 74 | { 75 | if(words[i].charAt(j) != words[i+1].charAt(j)) 76 | { 77 | g.addEdge(words[i].charAt(j) - 'a', words[i+1].charAt(j)- 'a'); 78 | break; 79 | } 80 | } 81 | } 82 | 83 | String ans = g.topologicalSort(); 84 | return ans; 85 | } 86 | } -------------------------------------------------------------------------------- /Milestone -3 Day 11-15 [ Microsoft ]/Q6_PossibleWordsFromPhoneDigits.java: -------------------------------------------------------------------------------- 1 | class Q6_PossibleWordsFromPhoneDigits{ 2 | // String array to store keypad characters 3 | static String hash[] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; 4 | 5 | //Function to find list of all words possible by pressing given numbers. 6 | static ArrayList possibleWords(int a[], int N) 7 | { 8 | String str = ""; 9 | for(int i = 0; i < N; i++) 10 | str += a[i]; 11 | ArrayList res = possibleWordsUtil(str); 12 | //arranging all possible strings lexicographically. 13 | Collections.sort(res); 14 | return res; 15 | 16 | } 17 | 18 | //recursive function to return all possible words that can 19 | //be obtained by pressing input numbers. 20 | static ArrayList possibleWordsUtil(String str) 21 | { 22 | //if str is empty 23 | if (str.length() == 0) { 24 | ArrayList baseRes = new ArrayList<>(); 25 | baseRes.add(""); 26 | 27 | //returning a list containing empty string. 28 | return baseRes; 29 | } 30 | 31 | //storing first character of str 32 | char ch = str.charAt(0); 33 | //storing rest of the characters of str 34 | String restStr = str.substring(1); 35 | 36 | //getting all the combination by calling function recursively. 37 | ArrayList prevRes = possibleWordsUtil(restStr); 38 | ArrayList Res = new ArrayList<>(); 39 | 40 | String code = hash[ch - '0']; 41 | 42 | for (String val : prevRes) { 43 | 44 | for (int i = 0; i < code.length(); i++) { 45 | Res.add(code.charAt(i) + val); 46 | } 47 | } 48 | //returning the list. 49 | return Res; 50 | } 51 | } 52 | 53 | 54 | 55 | 56 | 57 | 58 | /// Second Solution 59 | /* 60 | static ArrayList possibleWords(int a[], int n) 61 | { 62 | ArrayList ans=new ArrayList<>(); 63 | if(n==0) 64 | return ans; 65 | int index=0; 66 | String output=""; 67 | String[] keypad={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; 68 | solve(a,n,index,keypad,output,ans); 69 | return ans; 70 | } 71 | static void solve(int arr[],int n,int index,String keypad[],String output,ArrayList ans){ 72 | if(index>=n){ 73 | ans.add(output); 74 | return; 75 | } 76 | String temp=keypad[arr[index]]; 77 | for(int i=0;i num ? result : num; 11 | } 12 | } 13 | } 14 | return result; 15 | } 16 | public int search(int i,int j, int[][]grid) { 17 | 18 | if(i < 0 || j<0 || i >= grid.length || j >= grid[0].length || grid[i][j] == 0 ) 19 | return 0; 20 | 21 | grid[i][j] = 0; 22 | int sum = 0; 23 | sum += search(i+1,j,grid); 24 | sum += search(i,j+1,grid); 25 | sum += search(i,j-1,grid); 26 | sum += search(i-1,j,grid); 27 | 28 | sum += search(i+1,j+1,grid); 29 | sum += search(i-1,j-1,grid); 30 | sum += search(i+1,j-1,grid); 31 | sum += search(i-1,j+1,grid); 32 | return sum + 1; 33 | } 34 | } 35 | 36 | /* 37 | // Second solution 38 | 39 | class Solution 40 | { 41 | int count; 42 | //Function to check if a given cell (row, col) can be included in DFS. 43 | static boolean isSafe(int[][] M,int row,int col,boolean[][] visited,int ROW,int COL) 44 | { 45 | //if the cell is within the matrix bounds and value at cell is 1 and 46 | //the cell is not visited, we return true else false. 47 | return ((row >= 0)&&(row=0)&& (col < COL) 48 | && (M[row][col] == 1 && !visited[row][col])); 49 | } 50 | 51 | 52 | void DFS(int[][] M,int row,int col,boolean[][] visited,int ROW,int COL) 53 | { 54 | //these arrays are used to get row and column numbers 55 | //of 8 neighbours of a given cell. 56 | int[] dx = { -1, -1, -1, 0, 0, 1, 1, 1 }; 57 | int[] dy = { -1, 0, 1, -1, 1, -1, 0, 1 }; 58 | 59 | //marking the current cell as visited. 60 | visited[row][col] = true; 61 | 62 | //iterating over the adjacent cells. 63 | for (int k = 0; k < 8; k++) 64 | { 65 | //if cell indexes are within range, we increment the count 66 | //and call the function recursively. 67 | if (isSafe(M, row + dx[k], col + dy[k],visited, ROW, COL)) 68 | { 69 | count++; 70 | DFS(M, row + dx[k], col + dy[k],visited, ROW, COL); 71 | } 72 | } 73 | } 74 | 75 | //Function to find unit area of the largest region of 1s. 76 | public int findMaxArea(int[][] grid) 77 | { 78 | int ROW = grid.length; 79 | int COL = grid[0].length; 80 | 81 | //using boolean array to mark visited nodes. 82 | boolean[][] visited = new boolean[ROW][COL]; 83 | 84 | int result = 0; 85 | //traversing all the cells of the matrix. 86 | for (int i = 0; i < ROW; i++) 87 | { 88 | for (int j = 0; j < COL; j++) 89 | { 90 | //if a cell has value 1 is not visited, we call DFS function. 91 | if (grid[i][j] == 1 && !visited[i][j]) 92 | { 93 | count = 1; 94 | DFS(grid, i, j, visited, ROW, COL); 95 | 96 | //updating maximum area. 97 | result = Math.max(result, count); 98 | } 99 | } 100 | } 101 | return result; 102 | } 103 | } 104 | 105 | 106 | */ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #ReviseWithArsh #6Companies30Days #ArshGoyal 2 | 3 | # #ReviseWithArsh #6Companies30Days Challenge! 4 | 5 | [![ReviseWithArsh](https://img.shields.io/badge/Language-JAVA-934fb5?style=for-the-badge&logo=java&logoColor=white)](https://github.com/ankitkumar734ac/6Companies30days) 6 | [![ReviseWithArsh](https://img.shields.io/badge/ReviseWithArsh-6Companies30Days-green?style=for-the-badge&logo=github)](https://github.com/ankitkumar734ac/6Companies30days) 7 | 8 | Offical Doc:- Explore the docs »
9 | Offical Video:- Explore the Video »
10 |
11 |

Arsh Goldman Sachs Sheet :

12 | 13 | #### Day 1-5 : 14 | #### Company Name : Goldman Sachs 15 | 16 | :white_check_mark: 1. Given an array of strings, return all groups of strings that are anagrams.Link
17 | :white_check_mark: 2. Overlapping rectangles Link
18 | :white_check_mark: 3. Count the subarrays having product less than k Link
19 | :white_check_mark: 4. Given a string, Your task is to complete the function encode that returns the run length encoded string for the given string. eg if the input string is “wwwwaaadexxxxxx”, then the function should return “w4a3d1e1x6″.(Modified version of question named Cute Monkeys) Link
20 | :white_check_mark: 5. Program to find Nth Ugly Number. Link
21 | :white_check_mark: 6. Given two strings str1 and str2. We say that str2 divides str1 if it's possible to concatenate multiple str2 to get str1. For example, ab divides abab. if str2 does not divide str1, return -1. Otherwise, return the smallest string str3 such that str3 divides both str1 and str2. Link
22 | :white_check_mark: 7. Find the kid which gets tha damaged toy Link
23 | :white_check_mark: 8. Total Decoding Messages Link
24 | :white_check_mark: 9. Given a pattern containing only I's and D's. I for increasing and D for decreasing.Devise an algorithm to print the minimum number following that pattern. Link
25 | - [ ] 10. Find max 10 numbers in a list having 10M entries. Link
26 | 27 | :white_check_mark: 11. Given an unsorted array Arr of size N of positive integers. One number 'A' from set {1, 2, …N} is missing and one number 'B' occurs twice in array. Find these two numbers. Link
28 | :white_check_mark: 12. Find total number of Squares in a N*N chessboard Link
29 | :white_check_mark: 13. Decode the string Link
30 | :white_check_mark: 14. Minimum Size Subarray Sum Link
31 | :white_check_mark: 15. Array Pair Sum Divisibility Problem Link
32 |
33 |

Arsh Amazon Sheet :

34 | 35 | #### Day 6-10 : 36 | #### Company Name : Amazon 37 | 38 | Offical Doc:- Explore the docs »
39 | Offical Video:- Explore the Video »
40 |
41 | 42 | :white_check_mark: 1.Calculating Maximum Profit (Multiple Ladders Question)Link
43 | :white_check_mark: 2.Longest Mountain Link
44 | :white_check_mark: 3.IPL 2021 - Match Day 2 (similar to maximum in subarray)Link
45 | :white_check_mark: 4.Brackets in Matrix Chain Multiplication Link
46 | :white_check_mark: 5.Phone directory (Question similar to this based on Amazon Pay as a service)Link
47 | :white_check_mark: 6.Maximum of all subarrays of size kLink
48 | :white_check_mark: 7.First non-repeating character in a streamLink
49 | :white_check_mark: 8.Count ways to N'th Stair(Order does not matter)Link
50 | :white_check_mark: 9.Which among them forms a perfect Sudoku Pattern ?Link
51 | :white_check_mark: 10.Nuts and Bolts ProblemLink
52 | :white_check_mark:11.Tree Serialization and DeserializationLink
53 | :white_check_mark: 12.Column name from a given column numberLink
54 | :white_check_mark: 13.Rotten Oranges -Multiple RepetitionsLink
55 | :white_check_mark: 14.Tree Burning Link
56 | :white_check_mark: 15. Delete N nodes after M nodes of a linked list Link
57 |
58 |

Arsh Microsoft Sheet :

59 | 60 | #### Day 11-15 : 61 | #### Company Name : Microsoft 62 | 63 | Offical Doc:- Explore the docs »
64 | Offical Video:- Explore the Video »
65 |
66 | 67 | :white_check_mark: 1.Divide an array into two sets S1 and S2 such that the absolute difference between their sums is minimum and find the minimum difference Link
68 | :white_check_mark: 2.Prerequisite Tasks (Similar to Question of Modern Park)Link
69 | :white_check_mark: 3.Rotate by 90 degreeLink
70 | :white_check_mark: 4. Given a matrix of size r*c. Traverse the matrix in spiral form. Link
71 | :white_check_mark: 5. Stock span problemLink
72 | :white_check_mark: 6.Possible Words From Phone DigitsLink
73 | :white_check_mark: 7.Unit Area of largest region of 1's Link
74 | :white_check_mark: 8.Connect Nodes at Same LevelLink
75 | :white_check_mark: 9.Count Number of SubTrees having given Sum Link
76 | :white_check_mark: 10.Stickler Thief (Similar to Alibaba and Thiefes Question) Link
77 | :white_check_mark: 11.Generate and print all binary numbers with decimal values from 1 to N. Link
78 | :white_check_mark: 12.Find all the unique quadruple from the given array that sums up to the given number.Link
79 | :white_check_mark: 13.Given a Graph of V vertices and E edges and another edge(c - d), the task is to find if the given edge is a Bridge. i.e., removing the edge disconnects the graph.Link
80 | :white_check_mark: 14.Given a destination D , find the minimum number of steps required to reach that destination.Link
81 | :white_check_mark: 15.Find the order of characters in the alien language.Link
82 |
83 |

Arsh Adobe Sheet :

84 | 85 | #### Day 15-20 : 86 | #### Company Name : Adobe 87 | 88 | Offical Doc:- Explore the docs »
89 | Offical Video:- Explore the Video »
90 |
91 | - [ ] 1.Find a continuous sub-array which adds to a given number S.Link 92 | - [ ] 2.Find the length of the Longest Arithmetic Progression (LLAP) in it.Link 93 | - [ ] 3.Number of distinct Words with k maximum contiguous vowels(Joe and his Dictionary Problem)Link 94 | - [ ] 4.Partition Equal Subset SumLink 95 | - [ ] 5.Total number of ways n can be expressed as sum of xth power of unique natural numbersLink 96 | - [ ] 6.Generate all combinations of well-formed(balanced) parentheses.Link 97 | - [ ] 7.Pots of Gold Game (Similar to Covid and Beds problem)Link 98 | - [ ] 8.ATOI Link 99 | - [ ] 9. Smallest palindromic number greater than N using the same set of digits as in N.Link 100 | - [ ] 10.ElectionsLink 101 | - [ ] 11.String AmendmentLink 102 | - [ ] 12.Leaders in ArrayLink 103 | - [ ] 13.Minimum operations to convert array A to B Link 104 | - [ ] 14.Smallest range in K lists Link 105 | - [ ] 15.Given two library versions of an executable: for example, “10.1.1.3” and “10.1.1.9” or “10” and “10.1”. Find out which one is more recent? Strings can be empty also.Link 106 | --------------------------------------------------------------------------------