Both stages return the longest contiguous length with at most limit distinct strings. Empty labels or limit 0 return 0; negative limit throws invalid_argument. Prototype enumerates ranges; final uses one window and frequency map, expected O(n) time. Preserve input.
Public signatures:
Int prototype(const Vec<std::string>& labels,const Int& limit);
Int solve(const Vec<std::string>& labels,const Int& limit);Compile and run from this directory:
c++ -std=c++20 -O2 -Wall -Wextra -pedantic -pthread main.cpp -o practice
./practice --stage prototype
./practice --stage finalEdit exercise.hpp. Both stages start unfinished and must report failures until implemented. Keep main.cpp as the executable contract. The runner returns nonzero for a failed check, an unexpected exception, an invalid stage, or an empty suite. C++20 and only the standard library are required.
Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
Loading editor…
No results yet.
Complete the starter code, then run the checks.
Results and errors will appear here.
C++ runtime powered by Wasmer.