Skip to content

Instantly share code, notes, and snippets.

@AbdullahMagat
AbdullahMagat / Hackerrank Java Int to String Solution
Created July 28, 2018 23:46
Hackerrank Java Int to String Solution
import java.util.*;
import java.security.*;
public class Solution {
public static void main(String[] args) {
DoNotTerminate.forbidExit();
try {
Scanner in = new Scanner(System.in);
int n = in .nextInt();
@AbdullahMagat
AbdullahMagat / Hackerrank Java End-of-file Solution
Created July 28, 2018 23:19
Hackerrank Java End-of-file Solution
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i=0;
while(scan.hasNextLine()){
String str=scan.nextLine();
@AbdullahMagat
AbdullahMagat / Hackerrank Java Datatypes Solution
Created July 28, 2018 22:11
Hackerrank Java Datatypes Solution
import java.util.*;
import java.io.*;
import java.math.BigInteger;
class Solution{
public static void main(String []argh)
{
@AbdullahMagat
AbdullahMagat / Hackerrank Java Loops II
Created July 27, 2018 23:58
Hackerrank Java Loops II
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argh){
Scanner in = new Scanner(System.in);
int t=in.nextInt();
for(int i=0;i<t;i++){
int a = in.nextInt();
int b = in.nextInt();
@AbdullahMagat
AbdullahMagat / Hackerrank Java Anagrams Solution
Created July 26, 2018 19:19
Hackerrank Java Anagrams Solution
import java.util.Scanner;
public class Solution {
static boolean isAnagram(String a, String b) {
// // once you declare a.toUppercase you should assign it to a. you cannot define it as just a.toUppercase...
// //I solved it with the long way however I could put a and b in a character array and then use Arrays.sort(arrayname). after this steps convert them to string and check if they are equel.
a=a.toUpperCase();
b=b.toUpperCase();
boolean ret = false;
StringBuilder c= new StringBuilder(b);
@AbdullahMagat
AbdullahMagat / Hackerrank Java String Reverse
Created July 26, 2018 19:15
Hackerrank Java String Reverse
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String A=sc.next();
String str="Yes";
@AbdullahMagat
AbdullahMagat / Hackerrank Java Substring Comparisons
Created July 26, 2018 19:14
Hackerrank Java Substring Comparisons
import java.util.Scanner;
public class Solution {
public static String getSmallestAndLargest(String s, int k) {
String smallest = "";
String largest = "";
smallest = s.substring(0,k);
largest = s.substring(0,k);
// "Compare to" method doesn't turn just the equel case it also turns a value.
for(int i=0; i<=s.length()-k; i++ ){
String str = s.substring(i,k+i);