We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Well my solution is based on the fact that since is positive that means the first coefficient will be positive so the parabola will be concave up.
From the parabola we can easily conclude that the solution is between 1 and floor of first root and from ceil of second root to n only for those values the equation will be greater or equal to zero.
If the discriminant is imaginery then that means all values upto n will result in a positive answer for the equation.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Counting
You are viewing a single comment's thread. Return to all comments →
Well my solution is based on the fact that since is positive that means the first coefficient will be positive so the parabola will be concave up.
From the parabola we can easily conclude that the solution is between 1 and floor of first root and from ceil of second root to n only for those values the equation will be greater or equal to zero. If the discriminant is imaginery then that means all values upto n will result in a positive answer for the equation.