Chef and Median
CodeChefOpen on judge ↗
Chef has an empty list of numbers and N queries. Description of queries is as below: r x : remove number x if it is present in the list (only once) a x : add number x in the list (only once) After every operation, chef wants to find median of the list. If any operation is not possible, he wants you to print "invalid" (without quotes). The median of N numbers is defined as the middle number a
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.
Sign in to chat with the tutor and save your progress.
Sign in to start