Posts

Strange Table CodeForces

 import java.util.Scanner; class CodeForces7{ public static void main(String arg[]){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t -->0){ long n=sc.nextLong(); long m=sc.nextLong(); long x=sc.nextLong(); //long arr[][]=new long[n][m]; //By rows /* for(int i=1;i<n*m+1;i++){ if(i%m==0){ System.out.print(i); System.out.println(); } else  System.out.print(i+" "); }*//* int count=0; for(int i=1;i<n+1;i++){ for(int j=i;j<=(m*n);j+=n){ count++; if(count%m==0){ System.out.println(); } else System.out.print(j+" "); } } for(int i=1;i<2;i++){ System.out.print(i+" "); for(int j=i+1;j<=(m*n);j++){ //count++; if(j%m==0){ System.out.print(j); System.out.println(); } else System.out.print(j+" "); } } ...

Merging Two Strings

 import java.util.Scanner; class SolutionLe{ public static void main(String arg[]){ Scanner sc=new Scanner(System.in); String word1=sc.next(); String word2=sc.next(); int i=0,j=0; String s=""; while(i<word1.length() && j<word2.length()){ s=s+word1.charAt(i++); s=s+word2.charAt(j++); } while(i<word1.length()){ s=s+word1.charAt(i++); } while(j<word2.length()) { s=s+word2.charAt(j++); } System.out.println(s); } }

Day 6: Let's Review HACKKERANK

  import  java.io.*; import  java.util.*; public   class  Solution {      public   static   void  main(String[] args) {         Scanner sc= new  Scanner(System.in);          int  t=sc.nextInt();          while (t --> 0 ){             String s=sc.next();              for ( int  i= 0 ;i<s.length();i+= 2 ){                 System.out.print(s.charAt(i));             }             System.out.print( " " );       ...

Hackkerank problem solving Grading students

  import  java.io.*; import  java.math.*; import  java.security.*; import  java.text.*; import  java.util.*; import  java.util.concurrent.*; import  java.util.function.*; import  java.util.regex.*; import  java.util.stream.*; import   static  java.util.stream.Collectors.joining; import   static  java.util.stream.Collectors.toList; class  Result {      /*      * Complete the 'gradingStudents' function below.      *      * The function is expected to return an INTEGER_ARRAY.      * The function accepts INTEGER_ARRAY grades as parameter.      */      public   static  List<Integer> gradingStudents(List<Integer> grades)...

LEETCODE MINIMUM INCOMPATIBILITY 1681

 class Solution {     public int minimumIncompatibility(int[] nums, int k) {         int count=0;         int sum2=0;         if(nums.length%2==0){             if(nums.length%k==0){                 Arrays.sort(nums);                 int n=nums.length;                 int m=nums.length/k;                 int first=nums[0];                 int last=nums[n-1];                 int sum=0;                 int avg=0;                                  for(int i=0;i<n;i++){                 ...

GOOGLE QUESTION

 import java.util.ArrayList; import java.util.Scanner; class Google12{ public static void main(String arg[]){ Scanner sc=new Scanner(System.in); System.out.println("Enter sum value"); int n=sc.nextInt(); System.out.println("Enter no of elements in array"); int m=sc.nextInt(); int arr1[]=new int[m]; ArrayList<Integer> aa=new ArrayList<Integer>(); for(int i=0;i<m;i++){ arr1[i]=sc.nextInt(); aa.add(arr1[i]); } int sum=0; int count=0; for(int i=0;i<aa.size()-1;i++){ sum=sum+aa.get(i)+aa.get(i+1); if(sum==n){ count++; System.out.println("No are :"+ aa.get(i) + aa.get(i+1)); } else { sum=0; } } if(count!=0){ System.out.println("Ok Pairs exist and are: "+count); } else System.out.println("Pair dont exist"); } }