FastPrepSqrt(x)
Problems/Sqrt(x)

Sqrt(x)

LinkedIn logoLinkedIn● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A LinkedIn IC2 Apps phone screen had two coding questions after a resume talk. This one was the well-known integer square root task, linked by name in the post.

The post adds no examples, limits or rules of its own. Here the limits and the no-built-in rule follow the common version: x is from 0 to 2^31 - 1, and the answer is rounded down.

The judged task matches the post at about 95%.

You are given a non-negative integer x. Return the square root of x rounded down to a whole number. In other words, return the largest integer r such that r * r <= x.

Do not use a built-in square root or power function. Work it out with whole-number arithmetic.

Function

mySqrt(x: int) → int

Examples

Example 1

x = 4return = 2

2 * 2 = 4, which is not more than 4, and 3 * 3 = 9 is too big. So the answer is 2.

Example 2

x = 8return = 2

The real square root of 8 is about 2.83. Rounded down, that is 2: 2 * 2 = 4 <= 8, but 3 * 3 = 9 > 8.

Example 3

x = 2147483647return = 46340

This is the largest allowed x. 46340 * 46340 = 2147395600 is not more than x, but 46341 * 46341 = 2147488281 is. So the answer is 46340.

Constraints

  • 0 <= x <= 2^31 - 1

More LinkedIn Phone Screen questions

  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
  • Known Words Matching Phone DigitsPHONE SCREEN · Seen Oct 2026
  • Inverse-Depth Nested List SumPHONE SCREEN · Seen Oct 2026
  • Valid Number with ExponentsPHONE SCREEN · Seen Oct 2026
  • Sort a Quadratic-Transformed ArrayPHONE SCREEN · Seen Oct 2026
  • Constant-Time Minimum StackPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Route Length From Two CyclistsJane Street · PHONE SCREENJane Street interview questions
  • Pressure Chamber Linear InterpolationSpaceX · PHONE SCREENSpaceX interview questions
  • When to Accept a Doubled BetSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Integer Square Root with Error ChecksBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Square Root FunctionCitadel · PHONE SCREENCitadel interview questions
  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Convex Function MinimizationUber · PHONE SCREENUber interview questions
  • Square Root with Newton IterationGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Minimum of a Convex FunctionRippling · PHONE SCREENRippling interview questions
  • Minimum Full Glasses for an Exact Water VolumeMarshall Wace · PHONE SCREENMarshall Wace interview questions

LinkedIn interview experiences

  • LinkedIn Senior MLE Interview Questions: 1 Experience
  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public int mySqrt(int x) {
        // Write your code here.
    }
}
Checking account…