Posts

Featured Post

Strange Counter

Image
           Hacker Rank Solution              Strange Counter Hey guys ,welcome to another blog on hacker rank solution . this time we gonna discuss a hacker rank algorithim problem, which is named as Strange Counter Dashboard> Algorithms> Implementation >Strange Counter Solution:                  This one is little tricky question , After a close observation one will find it easy. the first solution arises in mind is by iterating through for loop till i==t and setting intital-value to 1 and count=3 and decreasing the value of "vount" by 1 at each iteration and as the value of "count" equals to 1 , we will double the initial-value and will initialise count to initial value.                                   But here a problem arises , which is time complexity , iteratinf through each value will give time out because remember t can vary from t=1 to t= 10 to the power 12. So another way of solving this is by jumping through each cycle r

Happy Ladybugs

Image
                      Hacker Rank Solution  Happy Ladybugs Hey guys ,welcome to another blog on  hacker rank solution . this time we gonna discuss a hacker rank  algorithim  problem, which is named as  Happy Ladybugs. Problem: Problem Breakdown: First of all let us understand the problem statement---- As described in the question that ladybugs is board game and the board is represented by a String b , each Charcter of string shows the type(by color) of ladybug(insect) at that place. for ex if any charcter of the String is 'X' ,then that ladybug is of color X. There can be any of the 26 types of ladybugs (i.e. UpperCase alphabates i.e. A to Z) If any character of string is underscore (' _ ') then it represent an empty place. As described above that we have to determine that all the ladybugs in the string are happy or not ,if not then they can be made happy through some no. of moves ? Solution : Have look at this test case :

The Hurdle Race

Image
Hacker Rank Solution The Hurdle Race Hey guys ,welcome to another blog on  hacker rank solution . this time we gonna discuss a hacker rank  algorithim  problem, which is named as  The Hurdle Race. See the example As it is very clear from the Example that ,to be able to cross all the hurdle , he should be able to jump the hurdle with the maximum height , so our first task is to find out the maximum of the array . After this, we have to find how much beverage he should drink to be able to jump the max-hurdle .this can be evaluted by subtracting the max of the array from K. Remember if K is equal or greater than max-hurdle  ,he can jump all the hurdles without drinking any beverages, so we will print zero  . Here is the code in java. import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution {     static int hurdleRace(int k, int[] height) {          int max=height[0];         for(int