LeetCode Solutions/Problem Group 2 (Flight Bookings)
Revision as of 20:21, 3 June 2025 by Vishwa (talk | contribs) (→LeetCode 1109. Corporate Flight Bookings)
LeetCode 1109. Corporate Flight Bookings
ZCUBES with KEYTAGS
bookings = [[1,2,10],[2,3,20],[2,5,25]],
n = 5;
ro={};
f=(x,y)=>ro[x]=(ro[x]||0) + y;
f#;
bookings.map(r=>f((r[0])..(r[1]),r[2]));
ro
KEYTAGS(ro).map(r=>[r[0],SUM(r[1])])
PRINT(ro)
ZCUBES using Object.entries
bookings = [[1,2,10],[2,3,20],[2,5,25]],
n = 5;
ro={};
f=(x,y)=>ro[x]=(ro[x]||0) + y;
f#;
bookings.map(r=>f((r[0])..(r[1]),r[2]));
ro
Object.entries(ro).map(r=>[r[0],SUM(r[1])]);
PRINT(ro)