Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6454 |

@blackshadows | 6380 |

@mb1973 | 5710 |

@Quandray | 5245 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5046 |

@sanjay05 | 3762 |

@kirtidee18 | 3709 |

@mantu_singh | 3556 |

@marius_valentin_dragoi | 3523 |

@sushant_a | 3459 |

Complete Leaderboard | |

Handle | Score |

@cfwong8 | 1285 |

@gurshehzadsingh | 1052 |

@pritsahkar2000 | 812 |

@nithinreddy3210 | 801 |

@satyamchhatrala | 796 |

@iib2019024 | 745 |

@mohanreddy8847 | 704 |

@iamchaitanyahegde | 662 |

@workit | 646 |

@shafeeq3543 | 645 |

@AkashLahoty | 642 |

Complete Leaderboard |

Given a set of **N** jobs where each job *i* has a deadline and profit associated to it. Each job takes *1* unit of time to complete and only one job can be scheduled at a time. We earn the profit if and only if the job is completed by its deadline. The task is to find the **maximum profit** and the number of jobs done.

**Note: **Jobs will be given in the form (Job id, Deadline, Profit) associated to that Job.

**Example 1:**

Input:N = 4 Jobs = (1,4,20)(2,1,10)(3,1,40)(4,1,30)Output:2 60Explanation:2 jobs can be done with maximum profit of 60 (20+40).

**Example 2:**

Input:N = 5 Jobs = (1,2,100)(2,1,19)(3,2,27) (4,1,25)(5,1,15)Output:2 127Explanation:2 jobs can be done with maximum profit of 127 (100+27).

**Your Task** :

You don't need to read input or print anything. Your task is to complete the function **JobScheduling()** which takes an Integer N and an array of Jobs(Job id, Deadline, Profit) as input and returns the count of jobs and maximum profit.

**Expected Time Complexity**: O(NlogN)

**Expected Auxilliary Space**: O(N)

**Constraints:**

1 <= N <= 10^{5}

1 <= Deadline <= 100

1 <= Profit <= 500

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Job Sequencing Problem

...