FastPrepPower with Integer Exponents
Problems/Power with Integer Exponents

Power with Integer Exponents

LinkedIn logoLinkedIn● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a LinkedIn onsite interview. Our version is about 99% the same as the reported question.

Implement myPow(x, n), which returns the real number x raised to the signed 32-bit integer exponent n.

Your implementation must handle zero and negative exponents and must not overflow when negating the minimum 32-bit integer.

Function

myPow(x: double, n: int) → double

Examples

Example 1

x = 2.0n = 10return = 1024.0

Multiplying ten factors of 2 gives 1024.

Example 2

x = 2.0n = -2return = 0.25

A negative exponent uses the reciprocal: 2^-2 = 1 / 4.

Constraints

  • n is any signed 32-bit integer.
  • If x is 0, then n is positive.
  • Answers are compared with relative or absolute tolerance 10^-9.

More LinkedIn Onsite Interview questions

  • Allocate Mailboxes with Squared DistanceONSITE INTERVIEW · Seen Nov 2026
  • Find Leaves of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Max Points on a LineONSITE INTERVIEW · Seen Nov 2026
  • Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026
  • Roll a Weighted DieONSITE INTERVIEW · Seen Oct 2026
  • Longest Binary Subarray With at Most K OnesONSITE INTERVIEW · Seen Oct 2026
  • Kth Closest Element in a BSTONSITE INTERVIEW · Seen Oct 2026
  • Longest Binary Window with at Most K OnesONSITE INTERVIEW · Seen Oct 2026
  • LRU Cache OperationsONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Path Between Two Nodes of a Fibonacci TreeDatabricks · PHONE SCREEN · ONSITE INTERVIEWDatabricks interview questions
  • Every Result of Grouping an ExpressionC3.ai · ONSITE INTERVIEWC3.ai interview questions
  • Pow(x, n)Bloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Integer Power Without a Library CallExpedia · ONSITE INTERVIEWExpedia interview questions
  • Fibonacci NumberMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Decision Tree Classifier from ScratchZillow · ONSITE INTERVIEWZillow interview questions
  • Josephus SurvivorApple · ONSITE INTERVIEWApple interview questions
  • N-th Fibonacci NumberBank of America · ONSITE INTERVIEWBank of America interview questions
  • Integer to English Words: Up to 20 DigitsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Fibonacci with Input ValidationMorgan Stanley · ONSITE INTERVIEWMorgan Stanley 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 double myPow(double x, int n) {
        // TODO: compute x raised to n.
    }
}
Checking account…