Posts

Showing posts from 2016

HackerRank : Sherlock And Squares

Watson gives two integers ( A A  and  B B ) to Sherlock and asks if he can count the number of square integers between  A A  and  B B  (both inclusive). Note : A square integer is an integer which is the square of any integer. For example,  1 ,  4 ,  9 , and  16  are some of the square integers as they are squares of  1 ,  2 ,  3 , and  4 , respectively. Input Format The first line contains  T T , the number of test cases.  T T  test cases follow, each in a new line. Each test case contains two space-separated integers denoting  A A  and  B B . Output Format For each test case, print the required answer in a new line. Constraints 1 ≤ T ≤ 100 1 ≤ T ≤ 100 1 ≤ A ≤ B ≤ 10 9 1 ≤ A ≤ B ≤ 10 9 Sample Input 2 3 9 17 24 Sample output 2 0 Explanation Test Case #00:  In range  [ 3 , 9 ] [ 3 , 9 ] ,  4 4  and  9 9  are the two square numbers....

HackerRank : StairCase

Your teacher has given you the task of drawing a staircase structure. Being an expert programmer, you decided to make a program to draw it for you instead. Given the required height, can you print a staircase as shown in the example? Input You are given an integer  N N  depicting the height of the staircase. Output Print a staircase of height  N N  that consists of # symbols and spaces. For example for  N = 6 N = 6 , here's a staircase of that height: # ## ### #### ##### ###### Note : The last line has 0 spaces before it. public class Solution {     public static void main(String[] args) {         Scanner in = new Scanner(System.in);         int n = in.nextInt();         for(int i=0;i<n;i++){             for(int j=1;j<=n;j++){                 System.out.print(j<n-i?" ":"#"); ...