FastPrepPowers of Two in a Range
Problems/Powers of Two in a Range

Powers of Two in a Range

Akuna Capital logoAkuna Capital● EasyNEW GRADINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Detailed reports ask for powers of two between two values. One Python report asks for the list 2, 4, 8, ..., 32 and a generator. Another follows a powers-of-two comprehension with powers of three. Some brief accounts only name powers of two without saying whether to list them, test a number, or compute exponents. We pick listing all powers in an inclusive range, as in the fuller reports. We chose the number limits, the order and what to do for exponent zero. The graded task stays powers of two. The editorial has a runnable generator and the powers-of-three follow-ups.

Our version is about 90% the same as the fuller reported questions.

Given two integers a and b, return every power of two from a to b, with both ends included, in increasing order.

A power of two is an integer of the form 2^k, where k is zero or more. This includes 1 = 2^0. Return an empty array if no power of two falls in the range.

Python follow-up: try writing the same selection as a list comprehension. Only the values your function returns are checked.

Function

powersOfTwo(a: int, b: int) → int[]

Examples

Example 1

a = 2b = 16return = [2,4,8,16]

For a = 2 and b = 16, the powers of two are 2, 4, 8 and 16, which are 2^1 up to 2^4. Both endpoints are included, so the answer is [2,4,8,16].

Example 2

a = 5b = 9return = [8]

Only 8 = 2^3 lies between 5 and 9, so the answer is [8].

Example 3

a = 3b = 3return = []

The only integer in the range is 3, which is not a power of two, so the answer is an empty array.

Constraints

  • 0 <= a <= 1000000000
  • 0 <= b <= 1000000000
  • a <= b

More Akuna Capital Phone Screen questions

  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Biased Coin: Probability of Exactly h HeadsPHONE SCREEN · Seen Nov 2026
  • Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Two SumOA · PHONE SCREEN · Seen Sep 2026
  • Maximum Value in a Binary TreePHONE SCREEN · Seen Sep 2026
  • Tiered Expiring Item StorePHONE SCREEN · Seen Aug 2026
  • Statistics for the Latest K ValuesPHONE SCREEN · Seen Nov 2025
  • Remove Duplicates While Preserving OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025
  • Sliding Window MaximumPHONE SCREEN · Seen Oct 2025
  • Evaluate a PolynomialPHONE SCREEN · Seen Oct 2025

Similar questions at other companies

  • Count the 1 Bits in a 32-Bit ValueAmazon · PHONE SCREEN
  • Even or Odd Without DivisionAdobe · PHONE SCREENAdobe interview questions
  • Power of Two Without DivisionArm · PHONE SCREEN
  • Choose the Next Minesweeper ActionRunloop · PHONE SCREEN
  • IP Address to CIDR BlocksOpenAI · PHONE SCREENOpenAI interview questions
  • Fewest Games to Find the Top Two TeamsSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
  • Address on Same PageNVIDIA · OANVIDIA interview questions
  • Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
  • Find the Missing Number from 1 to nGEP · OA

Interview reports that mention this question

  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
  • Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
  • Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public int[] powersOfTwo(int a, int b) {
        // write your code here
    }
}
Checking account…