PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Jane Street

Reach a Target Using Each Number At Most Once

Last updated: Jul 2, 2026

Reach a Target Using Each Number At Most Once

Company: Jane Street

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

# Reach a Target Using Each Number At Most Once You are given an array of integers `nums` and an integer `target`. Decide whether you can build an arithmetic expression that evaluates to exactly `target`, under the following rules: - Each **element** of `nums` may be used **at most once**. Elements with equal values count as separate elements. You do not have to use every element, but you must use at least one. - The numbers you pick may be arranged in any order and combined with the binary operators `+`, `-`, `*`, `/`, with any parenthesization. - Division is exact mathematical (rational) division: intermediate results may be non-integer fractions. Division by zero is not allowed at any step. - No unary minus, and no concatenating digits of different numbers (e.g. you may not glue `1` and `2` into `12`). - An expression consisting of a single picked number (no operators) is allowed, so if some element already equals `target`, the answer is `true`. Return `true` if `target` is reachable, otherwise `false`. Equality must be exact (rational arithmetic), not approximate floating-point equality. ## Examples **Example 1** ``` Input: nums = [1, 2, 3, 4], target = 24 Output: true ``` Pick `2`, `3`, `4` (leaving `1` unused): `2 * 3 * 4 = 24`. **Example 2** ``` Input: nums = [3, 3, 8, 8], target = 24 Output: true ``` `8 / (3 - 8 / 3) = 8 / (1/3) = 24`. Note the intermediate values are fractions — exact rational arithmetic matters. **Example 3** ``` Input: nums = [2, 5], target = 9 Output: false ``` All reachable values are `2`, `5`, `7`, `-3`, `3`, `10`, `2/5`, `5/2` — none equals `9`. ## Constraints - `1 <= nums.length <= 5` - `0 <= nums[i] <= 100` - `-10^4 <= target <= 10^4`

Related Interview Questions

  • Collapsible Code Editor: Brace Matching and Toggle - Jane Street (medium)
  • Implement a Circular Buffer - Jane Street (medium)
  • Code Editor with Block Shrink and Expand (Code Folding) - Jane Street (medium)
  • Optimize trade PnL table updates - Jane Street (hard)
  • Transform sparse time-code stream to dense rows - Jane Street (easy)
|Home/Coding & Algorithms/Jane Street

Reach a Target Using Each Number At Most Once

Jane Street logo
Jane Street
Sep 14, 2022, 12:00 AM
hardSoftware EngineerTechnical ScreenCoding & Algorithms
0
0

Reach a Target Using Each Number At Most Once

You are given an array of integers nums and an integer target. Decide whether you can build an arithmetic expression that evaluates to exactly target, under the following rules:

  • Each element of nums may be used at most once . Elements with equal values count as separate elements. You do not have to use every element, but you must use at least one.
  • The numbers you pick may be arranged in any order and combined with the binary operators + , - , * , / , with any parenthesization.
  • Division is exact mathematical (rational) division: intermediate results may be non-integer fractions. Division by zero is not allowed at any step.
  • No unary minus, and no concatenating digits of different numbers (e.g. you may not glue 1 and 2 into 12 ).
  • An expression consisting of a single picked number (no operators) is allowed, so if some element already equals target , the answer is true .

Return true if target is reachable, otherwise false. Equality must be exact (rational arithmetic), not approximate floating-point equality.

Examples

Example 1

Input:  nums = [1, 2, 3, 4], target = 24
Output: true

Pick 2, 3, 4 (leaving 1 unused): 2 * 3 * 4 = 24.

Example 2

Input:  nums = [3, 3, 8, 8], target = 24
Output: true

8 / (3 - 8 / 3) = 8 / (1/3) = 24. Note the intermediate values are fractions — exact rational arithmetic matters.

Example 3

Input:  nums = [2, 5], target = 9
Output: false

All reachable values are 2, 5, 7, -3, 3, 10, 2/5, 5/2 — none equals 9.

Constraints

  • 1 <= nums.length <= 5
  • 0 <= nums[i] <= 100
  • -10^4 <= target <= 10^4

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Jane Street•More Software Engineer•Jane Street Software Engineer•Jane Street Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.