LeetCode Solutions/Problem Group 2 (Flight Bookings)
Jump to navigation
Jump to search
LeetCode Problem 2 – 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)