0% found this document useful (0 votes)
40 views5 pages

Hackerrank Reverse

The document contains code for a Java program that takes user input of integers and a string. It then performs various calculations on the input values. Specifically, it counts the occurrences of a character in a string, calculates the number of characters greater than a given value t, and outputs the calculated value g which is a function of the character count, repetitions of the string, and remaining characters over t.

Uploaded by

saksham bajaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views5 pages

Hackerrank Reverse

The document contains code for a Java program that takes user input of integers and a string. It then performs various calculations on the input values. Specifically, it counts the occurrences of a character in a string, calculates the number of characters greater than a given value t, and outputs the calculated value g which is a function of the character count, repetitions of the string, and remaining characters over t.

Uploaded by

saksham bajaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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) {
    Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
       //  int d= (b-a)+1;
        int k = 0;
        int sum=0;
        while(k<4){
            int r=0;
            int z=a;
             while(a != 0) {
                 
                 //  get last  digit  from num
                 int digit = a % 10;
                 r = r * 10 + digit;
                 //  remove  the last  digit  from num
                 a /= 10;
                 
             }

               double h = (z-r)/c;
                 double check= Math.round(h);
                 if( check==h){
                     sum=sum+1;
                 }
                 else{
                     sum=sum+0;
                 }
                 z++;
                 k++;
        }    
             System.out.println(sum);
             
        
}
}

ROUND OF NAHI HO RAHAH


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) {
Scanner s= new Scanner(System.in); //System.in is a standard  input  str
eam   
//System.out.print("Enter a string:  ");  

String str= s.nextLine();  

long n = s.nextLong(); 

           
 long length=str.length();
double t=n%length;
int p=(int)t;
//System.out.println(t);
long e=n/length;
  // System.out.println(e);
   char someChar = 'a';
   //char  c  =  sc.next().charAt(0); 
int count = 0;
int remain=0;
 
for (int i = 0; i < str.length(); i++) {
    int te=str.charAt(i);
    if (str.charAt(i) == someChar) {
        count++;
    }
    if (te>t){
        remain++;
    }
    
}
if(t!=0){
    long g=(e*count)+remain;
     //long  g=gl;
    System.out.println(g);
}
else{
    long y=e*count;
    //long y=yl;
        System.out.println(y);

}
}

You might also like