Difference between revisions of "LeetCode Solutions/Problem Group 2 (Flight Bookings)"

From ZCubes Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
== LeetCode 1109. Corporate Flight Bookings ==
 
== LeetCode 1109. Corporate Flight Bookings ==
[[File:Leetcode1109.png|thumb|]
+
[[File:leetcode1109.png|thumb]]
 
=== ZCUBES with KEYTAGS ===
 
=== ZCUBES with KEYTAGS ===
 
<pre>
 
<pre>

Revision as of 20:21, 3 June 2025

LeetCode 1109. Corporate Flight Bookings

Leetcode1109.png

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)