Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function minPlatform(arr, dep) {
  2. let obj = new Object();
  3. let plat = 0;
  4. let result = 0;
  5. for (let i = 0; i < arr.length; i++) {
  6. obj[arr[i]] = "a";
  7. obj[dep[i]] = "d";
  8. }
  9. for (let i of Object.keys(obj)) {
  10. if (obj[i] == "a") {
  11. plat++;
  12. } else {
  13. plat--;
  14. }
  15. if (plat > result) {
  16. result = plat;
  17. }
  18. }
  19. return result;
  20. }
  21.  
  22. minPlatform(
  23. [900, 940, 950, 1100, 1500, 1800],
  24. [910, 1200, 1120, 1130, 1900, 2000]
  25. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement