FastPrepPower with Integer Exponents
Problems/Power with Integer Exponents

Power with Integer Exponents

NVIDIA logoNVIDIA● MediumFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported exponentiation task matches at about 90%. Signed exponents, zero handling, numeric bounds and precision are practice assumptions.

Given a real number x and integer n, implement myPow(x, n) to return x^n without a built-in power function.

For this exercise, a zero exponent returns 1 and a negative exponent returns the reciprocal of the positive power. When x = 0, n is positive.

Function

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

Examples

Example 1

x = 3.0n = 4return = 81.0

Four factors of three give 81.

Example 2

x = 4.0n = -2return = 0.0625

The reciprocal of sixteen is 0.0625.

Example 3

x = 2.5n = 0return = 1.0

Any nonzero base to exponent zero is one.

Constraints

  • -100 < x < 100; x is finite.
  • -2^31 <= n <= 2^31 - 1.
  • The mathematical result is between -10^4 and 10^4 and representable as a finite double; very small magnitudes may underflow to zero.
  • Outputs are compared using absolute or relative tolerance 10^-9.

More NVIDIA Phone Screen questions

  • Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
  • Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
  • Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
  • Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
  • Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
  • Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
  • Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
  • Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Path Between Two Nodes of a Fibonacci TreeDatabricks · PHONE SCREEN · ONSITE INTERVIEWDatabricks interview questions
  • Raise a Number to an Integer PowerAdobe · PHONE SCREENAdobe interview questions
  • Pow(x, n)Bloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Checked Recursive SumHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
  • Odd Numbers Up and BackNutanix · PHONE SCREENNutanix interview questions
  • FactorialZillow · PHONE SCREEN · ONSITE INTERVIEWZillow interview questions
  • Factorial Without MultiplicationWayve · PHONE SCREEN
  • Power with Integer ExponentsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Reach a Given NumberHyperVerge · OA
  • Is PossibleGoldman Sachs · OAGoldman Sachs interview questions

NVIDIA interview experiences

  • NVIDIA Full-Time SWE Onsite Scheduling: 1 Experience
  • NVIDIA OA: What It Tests (2026)
  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Software Intern Interview Questions: 9 Experiences
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public double myPow(double x, int n) {
        // Write your code here.
    }
}
Checking account…