Skip to main content

Posts

Showing posts with the label Algorithm

Modified Kaprekar Numbers Hackerrank Solution - java

 Modified Kaprekar Numbers Hackerrank Solution - java For explanation watch video : Code:: 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 'kaprekarNumbers' function below.      *      * The function accepts following parameters:      *  1. INTEGER p      *  2. INTEGER q      */     public static void kaprekarNumbers(int p, int q) {         ArrayList<Long> al = new ArrayList<>();         for(long i=p;i<=q;i++){             long sq = i*i;           ...

equalize the array hackerrank solution in java

 equalize the array hackerrank solution in java for explanation watch video :: code:: 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 'equalizeArray' function below.      *      * The function is expected to return an INTEGER.      * The function accepts INTEGER_ARRAY arr as parameter.      */     public static int equalizeArray(List<Integer> arr) {                 HashMap<Integer,Integer> hm = new HashMap<>();         for(int i=0;i<arr.size();i++){             hm.put(arr.get...

Library Fine Hackerrank Solution - java

 Library Fine Hackerrank Solution - java for explanation watch video : code: 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 'libraryFine' function below.      *      * The function is expected to return an INTEGER.      * The function accepts following parameters:      *  1. INTEGER d1      *  2. ...

Chocolate Feast Hackerrank Solution - java

Chocolate Feast Hackerrank Solution - java for explanation watch video : code: 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 'chocolateFeast' function below.      *      * The function is expected to return an INTEGER.      * The function accepts following parameters:      *  1. INTEGER n      *  2. INTEGER c      *  3. INTEGER m      */     public static int chocolateFeast(int n, int c, int m) {         //no of  chocolate          int num = n/c;         int w...

Grid Challenge Hackerrank Solution - java | Hackerrank Algorithm

 Grid Challenge Hackerrank Solution - java  For Explanation Watch Video :: Code :: 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 {           public   static  String sort(String s){          char [] ch = s.toCharArray();         Arrays.sort(ch);          return   new  String(ch);     }      public   static  String gridChallenge(List<String> grid...

Marc's Cakewalk Hackerrank Solution - Java | Hackerrank Algorithms

 Marc's Cakewalk Hackerrank Solution - Java  For Explanation watch video : Code : 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 'marcsCakewalk' function below.      *      * The function is expected to return a LONG_INTEGER.      * The function accepts INTEGER_ARRAY calorie as parameter.      */      public   static...

Jumping on the Clouds Hackerrank Solution - java

 Jumping on the Clouds Hackerrank Solution - java for explanation Watch video : Code :  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; public   class  Solution {      public   static   void  main(String[] args)  throws  IOException {         Scanner scn =  new  Scanner(System.in);          int  n = scn.nextInt();          int [] arr =  new   int [n];        ...

Repeated String Hackerrank Solution - java

 Repeated String Hackerrank Solution - java  For Explanation Watch Video : Code :  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 {      public   static   int  noOfA(String s, long  rem){          int  count =  0 ;          for ( int  i= 0 ;i<rem;i++){              if (s.charAt(i)== 'a' ){                 count++;  ...

Apple and Orange Hackerrank Solution - Java

 Apple and Orange Hackerrank Solution - Java For Explanation Watch Video: Code:: 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 'countApplesAndOranges' function below.      *      * The function accepts following parameters:      *  1. INTEGER s      *  2. INTEGER t      *  3. INTEGER a     ...

Mini-Max Sum Hackerrank Solution - java

 Mini-Max Sum Hackerrank Solution - java For Explanation Watch the video: Code:: 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 'miniMaxSum' function below.      *      * The function accepts INTEGER_ARRAY arr as parameter.      */     public static void miniMaxSum(List<Integer> arr) {         Collections.sort(arr);         long sum = 0;         for(int i=0;i<arr.size();i++){             sum += arr.get(i);         }         long low_sum = sum - arr.get(arr.size(...

Mars Exploration Hackerrank Solution - java

 Mars Exploration Hackerrank Solution - java For Explanation watch video:  Code::   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 'marsExploration' function below.      *      * The function is expected to return an INTEGER.      * The function accepts STRING s as parameter.      */     public static int findDifferentLetters(String s){         int count = 0;         if(s.charAt(0)!='S'){             count++;         }          if(s.charAt(1)!='O'){  ...

Picking Numbers Hackerrank Solution - java

 Picking Numbers Hackerrank Solution - java  Code:: 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; public   class  Solution {      public   static   void  main(String[] args)  throws  IOException {          int [] arr =  new   int [ 100 ];         Scanner scn =  new  Scanner(System.in);          int  n = scn.nextInt();          for ( int  i= 0 ;i<...

Hackerrank Designer PDF Viewer Solution - Java

 Hackerrank Designer PDF Viewer Solution - Java For Explanation Watch Video:: Code:: 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 'designerPdfViewer' function below.      *      * The function is expected to return an INTEGER.      * The function accepts following parameters:      *  1. INTEGER_ARRAY h      *...