DarwinBox OA Round

This was one of the question asked in the Online Round of DarwinBox for the role of Product Development Engineer Intern + Full Time

Base pay: 8.0L
CTC: 16.0L
Intern Stipend: 25k per month

Problem Statement

In Charlie and the Chocolate factory , the factory owner decided to select the winner by a competition. In the competition there are N chocolates and they have to calculate in how many days they can eat N chocolates provided some condition. On the first day, it is allowed to eat max 1 chocolate. If he eats i chocolates on a given day, he can eat i,i+1 or i-1 chocolates on the next day. On the last day, he can’t eat more than 1 chocolate. Now Charlie wants to win the game. He is good at programming so he thinks to find the answer by programming . Now help Charlie to win the competition.

Input Format

The first line contains an integer T (1 <T <1000) denoting the number of test cases.
Each of the next Tlines contains an integer N (1<
N<
10^9).

Output Format

Output T lines. On each line output the minimum number of days for each test case,

Sample Input

3
9
1
4

Sample output

5
1
3

Explanation

Case 1:1 + 2 + 3 + 2 + 1

Case 2:1

Case 3:1 + 2 + 1

Can someone explain the process and intuition behind this problem. Thanks in Advance

Comments (6)