Solved LeetCode program · 897 of 1,000
#1235 · Maximum Profit in Job Scheduling
Original English source
Keep a shared begins holding 1, 2, 3, and 3. Keep a shared ends holding 3, 4, 5, and 6. Keep a shared gains holding 50, 10, 40, and 70. Keep a shared best of 0. Keep a shared ready of 0.
To Walk from spot (a whole number) with total (a whole number). If spot is more than the last position of begins and total is more than best, set best to total. If spot is more than the last position of begins, return. Walk from spot plus 1 with total. If item spot of begins is at least ready, Improve from spot with total.
To Improve from spot (a whole number) with total (a whole number). The finish is item spot of ends. The gained is total plus item spot of gains. The old is ready. Set ready to finish. Walk from spot plus 1 with gained. Set ready to old.
Set ready to 0. Walk from 0 with 0. Show best.
Expected stdout
120