← All problemsSign in

1405. Longest Happy String

LeetCodeStringGreedyHeap (Priority Queue)Open on judge ↗

A string s is called happy if it satisfies the following conditions: - s only contains the letters 'a', 'b', and 'c'. - s does not contain any of "aaa", "bbb", or "ccc" as a substring. - s contains at most a occurrences of the letter 'a'. - s contains at most b occurrences of the letter 'b'. - s contains at most c occurrences of the letter 'c'. Given three integers a, b, and c, return the lo

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