Leaderboard
Showing:
Min value of x
Basic Accuracy: 13.63% Submissions: 22 Points: 1

Given 4 integers a,b,c and k . Find the min(non-negative Integral) value of x such that ax2+bx+c >= k.

Example 1:

Input: a = 4, b = 6, c = 5, k = 5
Output: 0
Explanation: 4*(0)2+6*0+5 = 5 which is
>= 5.


​Example 2:

Input: a = 1, b = 2, c = 3, k = 4 
Output: 1 
Explanation: 1*(1)2+2*1+3 = 6 which is
​>= 4.

Your Task:  
You don't need to read input or print anything. Your task is to complete the function minX() which takes a, b, c and as inputs and returns the answer.

Expected Time Complexity: O(log k)
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ a, b, c ≤ 105
1 ≤ k ≤ 109

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Min value of x

Output Window