How To Solve Angry Professor HackerRank Problem
Aug 15, 2023
How To Solve Angry Professor HackerRank Problem
In this video, I have explained hackerrank angry professor solution algorithm. hackerrank angry professor problem can be solved by using one for loop. The complexity of angry professor hackerrank solution is O (n). This hackerrank problem is a part of Practice | Algorithms | Implementation | Angry professor hackerrank challenge. For simplicity, I have divided this hackerrank tutorial into 3 parts. [00:00] Understanding the problem statement. [01:07] Building the logic to solve the problem. [04:20] Coding the logic using java (you can use your own preferred programming language). 🔴 DONT CLICK THIS: https://bit.ly/2G4cEuc 👍 Like us on Facebook:   / hackerranksolutiontutorials  💎Share this video with a YouTuber friend:    • How To Solve Angry Professor HackerRa…  ✚ Join our community ► 👉 Coding interview preparation group:   / codingip  👉 Telegram link: https://t.me/hackerranksolutions 📖 Resources ► 🙋 Problem statement: https://www.hackerrank.com/challenges … 💡 Source code: https://github.com/Java-aid/Hackerran … ✅ Recommended playlists ► 👉 All hackerrank solutions:    • How To Master In Data Structures And …  👋 Let’s Connect ► Git Hub: https://github.com/kanahaiya Twitter:   / kanahaiyagupta  Linked in:   / kanahaiya-gupta  Facebook:   / coolkanahaiya  Instagram:   / coolkanahaiya  #JAVAAID #angryprofessor #HackerRankSolutions #HackerRankTutorials #HackerRank #JavaAidTutorials #programming #DataStructures #algorithms #coding #competitiveprogramming #java #codinginterview #problemsolving #KanahaiyaGupta #hackerrankchallenges #Implementation
Content
0.03 -> Hello everyone welcomes to my youtube
channel today we are going to discuss
5.49 -> Angry professor hackerrank problem.
In this problem, we have given the arrival
12.15 -> time of each student and a threshold
number of attendees, we have to determine
18.57 -> if the class is cancelled or not. So here
are some points which we need to
25.529 -> consider, If the arrival time is less
than equal to 0. It means the student reach
32.6 -> the class on or before time and If arrival
time is greater than 0 students arrived late.
40.44 -> Guys, Here I am hoping you have already
gone through the problem description ones
47.19 -> if not please go through it to get a better idea. now try to
55.079 -> understand the same problem with the help of an
example. I am taking the same example
62.07 -> guys and will try to understand how this
problem can be solved. So, we have an
68.22 -> an array of 6 elements which contains the
the arrival time of 6 students and a
75.27 -> threshold value. So, let's plot this
arrival time on a graph you'll see what
81.66 -> happens, so let's see how the execution
will happen. Let's take the first element
89.52 -> We have -1 so the student came
somewhere here
96.65 -> and the 2nd student also came at -1 somewhere
here and the third student came at 0
107.43 -> the fourth student also came at 0
and now the fifth one student came at 1
119.49 -> and the sixth one also came at 1
So as mentioned in a question guys, if the
129.929 -> arrival time is less than equals to 0
it means the students came on or before
135.45 -> time so, this portion these are the students
140.43 -> who came on or before time and here the
right highlighted area it means this
149.4 -> students came after the arrival
time when the class starts.
156.84 -> equals to 2 students which came late and there are
four students which came on or before time
164.4 -> and we have threshold value which is
k=4. So, if the number of
172.319 -> students are equal to the threshold value(k=4)
it means the class
180.45 -> will happen. if it is less than that and
the class will cancel. So same thing we
187.38 -> have to achieve in a programmatic way.
we are going to loop through all the
195.98 -> elements in the array and try to see
how many elements/students are present on or
207.569 -> before time these students. So, we have to
compare the array element from less than
217.079 -> equals to 0. So, if an element is less than
equals to 0 that student or element
223.41 -> going to fall in a left side, this category
and if it's greater than 0 this will
231.239 -> fall here which arrived late so after
calculating how many students came on
239.519 -> or before the time we need to just check
whether these students are meeting the threshold value
245.37 -> or not. If this value is greater than or
equal to the threshold value which is k=4 .it means the
251.7 -> the class will happen otherwise the class
will be cancelled. Let's see the same
257.64 -> thing in program guys. So, this is the
263.66 -> function guys angry professor. Here we
have given a threshold value K and an
269.61 -> an array of arrival times. So, we have taken
a variable count=0 which will maintain
275.33 -> the number of students was present on or
before time. Here we are looping through
282.63 -> this array. This is a for loop and that I
have already showed, we are just checking
290.55 -> whether the element or arrival time is
less than equals to 0 or not. if it is less than
296.85 -> equals to 0 it means it lies in left
a portion of the time or you can say the
302.8 -> people who came
on or before time so we are just
307.02 -> calculating the number of students who
came on or before time. So, after that we
312.32 -> are just comparing with the threshold
value if the student who came on or
320.28 -> before time is greater than equals to
threshold value then the class will not be
326.62 -> cancelled it will happen so the class will
not be cancelled so it means we have to
333.72 -> send “NO” as an answer and if it's not meeting
this condition then the class will be
342.3 -> cancelled we have to send “YES”
let's copy this code and run on the hackerrank platform
352.76 -> So, I have pasted my code here and we'll try to run this so, guys, sample test case got passed, Let's submit now.
363.48 -> So, you can see all test
the case got passed guys I hope you understood
370.74 -> this problem thanks for watching guys
and if you want to download the source
375.15 -> the code you can go to my GitHub link which is mentioned in the below description box.
378.8 -> Thanks for watching
Source: https://www.youtube.com/watch?v=3hvzKDJQypI