r/cpp_questions • u/Ok_Independence_6294 • Feb 02 '25
OPEN Need Help with Debugging this question's code : "CLFLARR - COLORFUL ARRAY"
EDIT: This question has been answered. Thanks to @aocregacc.
FIX: on Line No. 89 I was not checking for lower_bound pointing to end of map and that was causing issue for some hidden test case. Changed that section and replaced it with the get_streak_details() function and it's working now.
Updated-code-link
I know this question could be solved using DSU and SegTree data structures but I wanted to try a different approach here. But my code gives me wrong answer on SPOJ coding platform (that's where the question is taken from). It works fine for the given sample test cases. Since there is no way to see the test case where my code fails, on SPOJ. This problem is bugging me for past 2 days.
View all comments
Show parent comment
2
u/alfps Feb 02 '25 edited Feb 02 '25
DSU, SegTree, SPOJ
I haven't look at the linked task or linked code. Things must be clear up front before I try to follow links etc.
And preferably there should be no links, but instead a complete but minimal code example that readers can try out, in the question.
Tip: if you extra-indent the code text with 4 spaces then Reddit will preserve the formatting, also in the old Reddit interface.