Square Root (Integral) Problem Statement
Given a number N
, calculate its square root and output the integer part only.
Example:
Input:
18
Output:
4
Explanation:
The square root of 18 is approximately 4.24. The integer part is 4.
Constraints:
0 ≤ N <= 108

AnswerBot
4mo
Calculate the integer square root of a given number.
Use binary search to find the square root of the number.
Start with a range from 0 to N, and iteratively narrow down the range until you find the int...read more
Kamakshi Dhankar
2y
import java.util.Scanner ;
public class Main {
public static void main(String[] args) {
// Write your code here
int i = 1 , result =1 ;
Scanner s = new Scanner(System.in);
int N = s.nextInt();
while(result<=N) {
i++ ;
result = i*i ;
}
System.out.println( i- 1 );
}
}
Help your peers!
Add answer anonymously...
Oracle Software Developer interview questions & answers
A Software Developer was asked 7mo agoQ. What is testing? Explain the different types of testing.
A Software Developer was asked 9mo agoQ. Given an array containing duplicate elements, remove the duplicates while mainta...read more
A Software Developer was asked 9mo agoQ. The count-and-say sequence is a sequence of digit strings defined by the recursi...read more
Popular interview questions of Software Developer
A Software Developer was asked 6mo agoQ1. Explain Linux system calls with an example.
A Software Developer was asked 7mo agoQ2. What is testing? Explain the different types of testing.
A Software Developer was asked 9mo agoQ3. Given an array containing duplicate elements, remove the duplicates while mainta...read more
Top HR questions asked in Oracle Software Developer
A Software Developer was asked 5mo agoQ1. Tell me about your work experience.
A Software Developer was asked 5mo agoQ2. What are your strengths?
A Software Developer was asked 5mo agoQ3. Can you tell me about yourself?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

