HackerEarth's basic programming solutions( Split houses, e-maze-in, Bricks Game, Lift queries ) :
Problem 11: Split houses
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
We replaced all the dots in our string s with B because it's written in the question "if there are many answers, then you are required to print the one where most fences are placed".
string1.compare(string2) function compares two strings and if the two strings are identical it returns 0 else 1.
Initially f = 0 , if f becomes -1 , it means that in the updated string s two H are together (which we don't want)
n=1 means , there is only one character in the string.
Problem 12: e-maze-in
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
Here the concept used is: In a two-dimensional Cartesian system , you can see if we move left by 1unit the value of x is decreased by 1 unit and there's no change in the value of y. similarly if we move right by 1 unit , x is increased by 1 unit and there's no change in the value of y. Similarly if we go up by 1 unit y increases by 1 and no change in the value of x and if down by 1 unit , y decreases by 1 value and no change in x value.
Problem 13: Bricks Game
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
Here i did what is exactly said in the question.
Example: 13 bricks are there :
Patlu Motu
1 2
2 4
3 1 ( Only 1 remains)
Hence, Motu puts the last one.
Similarly in the above code , while loop runs till n becomes 0. We initialize i with 1 and it will get incremented by 1 every time in the end of the while loop using i++. Use the example to understand the above code by putting values.
Problem 14: Lift queries
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
When the differences are equal , it means that both the lift are equidastance from the given floor and in the question it is clearly mentioned "If both the lifts are at equidistant from the N th floor, them the lift from the lower floor comes up" , Therefore checking which lift is at lower position by comparing a and b.
Guys , if you have any queries related to a question or need more explanation, comment down below!
Very well written about hackerearth splithouses emazein bricksgame. If you want videos of bricks game, please download vidmate.Not only this, if you love watching TV shows or any reality show coming on TV is your favorite then you don't want to miss it but due to some problem you are not able to watch that show on TV, Vidmate help application from. You can easily watch TV on your mobile phone. . With its help, you can also watch reality shows. And if you want to watch comfortably then you can download that reality show in your phone which is directly saved in gallery. And you can enjoy watching offline anytime later. You can also download bricks game and Vidmate from 9apps
ReplyDelete