# Puzzle 16) Dollars and Cents

Submitted by Abhishek Jain, on August 11, 2017

**Puzzle**

A man entered a store and spent one-half of the money that was in his pocket.

When he came out, he found that he had just as many cents as he had dollars when he went in and half as many dollars as he had cents when he went in.

How much money did he have when he entered the store?

**Important points of puzzle:**

- A man went to a store and spent half of the money from his pocket.
- When he came out, he found that he had same number of cents as he had dollars before entering the store.
- And he had half as many dollars as he had cents when he went in.
- Task: You Have to find, how much money did he have when he entered the store?

**Answer**

**$99.98**

**Reason**

He spent one-half of the money = **$49.99**

Money Remains in his pocket= **$49.99**

**Acc. To Statement:**

**(i)** No. of Dollars before he went in = **99**

No. of Cents after he came out =No. of Dollars before he went in = **99**

**(ii)** No. of Cents before he went in = **98**

No. of Dollars after he came out = half of cents he had before he went in= **98/2** = **49**.

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