← All problemsSign in

2522. Partition String Into Substrings With Values at Most K

LeetCodeStringDynamic ProgrammingGreedyOpen on judge ↗

You are given a string s consisting of digits from 1 to 9 and an integer k. A partition of a string s is called good if: - Each digit of s is part of exactly one substring. - The value of each substring is less than or equal to k. Return the minimum number of substrings in a good partition of s. If no good partition of s exists, return -1. Note that: - The value of a string is its result whe

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start