Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Power Of Numbers

Medium Acceptance 20.22% Points 30

Given a number n, compute the value of n raised to the power of its reverse.

Note: The result will always fit within the range of a 32-bit signed integer.

Examples
Example 1

Example 1

Input: n = 3

Output: 27

Explanation: The reverse of 3 is 3, and 3^3 = 27.

Example 2

Example 2

Input: n = 5

Output: 25

Explanation: The reverse of 5 is 5, and 5^5=25.

Constraints
  • 1 <= n <= 10
Hints
  • Expected Time Complexity: O(log n)
  • Expected Auxiliary Space: O(log n)
Topics
Recursion
Companies
Samsung Walmart
Added 28 Dec 2024 20.22% acceptance
Ln 1, Col 1Sign in to save your code
5
3125