From af69e3331464a2c15ed74824659032a1d5e7b689 Mon Sep 17 00:00:00 2001 From: shreya40 <88774355+shreya40@users.noreply.github.com> Date: Tue, 30 Nov 2021 21:26:17 +0530 Subject: [PATCH 1/2] Create container_with_water.java --- SHREYA_MISHRA/container_with_water.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 SHREYA_MISHRA/container_with_water.java diff --git a/SHREYA_MISHRA/container_with_water.java b/SHREYA_MISHRA/container_with_water.java new file mode 100644 index 0000000..45c012c --- /dev/null +++ b/SHREYA_MISHRA/container_with_water.java @@ -0,0 +1,17 @@ +class Solution { +public int maxArea(int[] height) { +int i=0; +int j = height.length-1; +int ans = 0; +while(i Date: Tue, 30 Nov 2021 21:31:18 +0530 Subject: [PATCH 2/2] Create job_sequence.java --- SHREYA_MISHRA/job_sequence.java | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 SHREYA_MISHRA/job_sequence.java diff --git a/SHREYA_MISHRA/job_sequence.java b/SHREYA_MISHRA/job_sequence.java new file mode 100644 index 0000000..c80a3a0 --- /dev/null +++ b/SHREYA_MISHRA/job_sequence.java @@ -0,0 +1,42 @@ +class Solution +{ + //Function to find the maximum profit and the number of jobs done. + int[] JobScheduling(Job arr[], int n) + { + int res[]=new int[2]; + res[0]=0; + res[1]=0; + Set slot=new HashSet<>(); + List list=new ArrayList<>(); + for(Job item:arr) + list.add(item); + Collections.sort(list,(n1,n2)->{ + return n2.profit - n1.profit; + }); + for(Job job:list) + { + int dead=job.deadline; + if(!slot.contains(dead)) + { + slot.add(dead); + res[0]+=1; + res[1]+=job.profit; + } + else + { + while(dead-->1) + { + if(!slot.contains(dead)) + { + slot.add(dead); + res[0]+=1; + res[1]+=job.profit; + break; + } + } + } + } + return res; + } +} +