# Puzzle 7) Krishna and his savings

Submitted by Amit Shukla, on August 05, 2017

**Puzzle**

A boy named Krishna lives in Indore in hostel. Krishna’s father gives him pocket money in every 3 months. One day Krishna thinks that he should starts saving his pocket money and he decides to start saving his money for future. On 1^{st} January 2017, Krishna saved 1Rs. Everyday starting from 2^{nd} January 2017, he saved1Rs more than previous day. Now you have to find out the first date at which the amount saved by Krishna will be a perfect square?

**Important points of puzzle:**

- Krishna’s father gives him pocket money in every 3 months.
- Krishna starts saving his money.
- On 1
^{st}January 2017 Krishna saved 1Rs. - Everyday starting from 2nd January 2017 he saved 1Rs more than previous day.
- Find the first day in which saving amount is a perfect square?

**Answer**

8^{th} January 2017.

**Reason**

On first day Krishna saves 1Rs and after each day he saves 1Rs more than previous day. Hence after 8 days saving became 36Rs which is a perfect square. So, the answer is 8th January 2017.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions