LeetCode Solutions/Problem Group 2 (Flight Bookings)

Revision as of 17:31, 3 June 2025 by Vishwa (talk | contribs) (Created page with "== LeetCode Problem 2 – Flight Bookings == === ZCUBES with KEYTAGS === <pre> bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5; ro={}; f=(x,y)=>ro[x]=(ro[x]||0) + y; f#; book...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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)