Tap here to switch tabs
Problem
Submissions

Problem: Least Operators to Express Number

Least Operators to Express Number asks you to use only x and the four arithmetic operators to form target, with standard precedence and no parentheses, returning the minimum operator count.

Statement

Given two integers x and target, return the minimum number of operators required to construct a valid mathematical expression that evaluates to target.

The expression must satisfy the following conditions:

  • The only operand permitted is x.

  • The available operators are addition (+), subtraction (-), multiplication (*), and division (/).

  • Standard operator precedence applies, meaning multiplication and division are evaluated before addition and subtraction.

  • Parentheses are not permitted.

  • Division x / x evaluates to 11.

Constraints:

  • 2≤2 \leq x ≤100\leq 100

  • 1≤1 \leq target ≤2×108\leq 2 \times 10^8

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Least Operators to Express Number

Least Operators to Express Number asks you to use only x and the four arithmetic operators to form target, with standard precedence and no parentheses, returning the minimum operator count.

Statement

Given two integers x and target, return the minimum number of operators required to construct a valid mathematical expression that evaluates to target.

The expression must satisfy the following conditions:

  • The only operand permitted is x.

  • The available operators are addition (+), subtraction (-), multiplication (*), and division (/).

  • Standard operator precedence applies, meaning multiplication and division are evaluated before addition and subtraction.

  • Parentheses are not permitted.

  • Division x / x evaluates to 11.

Constraints:

  • 2≤2 \leq x ≤100\leq 100

  • 1≤1 \leq target ≤2×108\leq 2 \times 10^8