you give 0indexed integer array num removequerie length n for ith query element num index removeQueriesi remove splitting num different segmentsA segment contiguous sequence positive integer num a segment sum sum element segmentreturn integer array answer length n answeri maximum segment sum apply ith removalNote the index remove Example 1input num 12561 removequerie 03241output 147220explanation using 0 indicate remove element answer followsquery 1 Remove 0th element num 02561 maximum segment sum 14 segment 2561query 2 Remove 3rd element num 02501 maximum segment sum 7 segment 25query 3 Remove 2nd element num 02001 maximum segment sum 2 segment 2 Query 4 Remove 4th element num 02000 maximum segment sum 2 segment 2 Query 5 Remove 1st element num 00000 maximum segment sum 0 segmentsfinally return 147220example 2input num 32111 removequerie 3210output 16530explanation using 0 indicate remove element answer followsquery 1 Remove 3rd element num 32110 maximum segment sum 16 segment 3211query 2 Remove 2nd element num 3200 maximum segment sum 5 segment 32query 3 Remove 1st element num 3000 maximum segment sum 3 segment 3query 4 Remove 0th element num 0000 maximum segment sum 0 segmentsfinally return 16530 Constraintsn numslength removequerieslength1 n 1051 numsi 1090 removeQueriesi nAll value removequerie unique