Tap here to switch tabs
Problem
Submissions

Problem: Partition String Into Minimum Beautiful Substrings

Partition String Into Minimum Beautiful Substrings asks you to divide a binary string into the fewest substrings. Each must have no leading zeros and represent a power of five; return -1 if impossible.

Statement

Given a binary string s, partition it into the minimum number of beautiful substrings.

A substring is considered beautiful if:

  • It does not contain any leading zeros.

  • It is the binary representation of a power of 55 (such that the value equals 5k5^k for some integer k≥0k \geq 0).

Return the minimum number of beautiful substrings into which s can be partitioned. If it is impossible to partition s this way, return −1-1.

Constraints:

  • 1≤1 \leq s.length ≤15\leq 15

  • s[i] is either '0' or '1'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Partition String Into Minimum Beautiful Substrings

Partition String Into Minimum Beautiful Substrings asks you to divide a binary string into the fewest substrings. Each must have no leading zeros and represent a power of five; return -1 if impossible.

Statement

Given a binary string s, partition it into the minimum number of beautiful substrings.

A substring is considered beautiful if:

  • It does not contain any leading zeros.

  • It is the binary representation of a power of 55 (such that the value equals 5k5^k for some integer k≥0k \geq 0).

Return the minimum number of beautiful substrings into which s can be partitioned. If it is impossible to partition s this way, return −1-1.

Constraints:

  • 1≤1 \leq s.length ≤15\leq 15

  • s[i] is either '0' or '1'.