Windows 7: How To Automate Tasks With The Task Scheduler

❣ Chile in a Photography ❣

blake kathryn
🪼

@theartofmadeline
No title available
trying on a metaphor
Sade Olutola
cherry valley forever
hello vonnie
No title available

JVL
he wasn't even looking at me and he found me

roma★

izzy's playlists!
sheepfilms
Monterey Bay Aquarium

Janaina Medeiros
will byers stan first human second
let's talk about Bridgerton tea, my ask is open
Aqua Utopia|海の底で記憶を紡ぐ
seen from United States
seen from Malaysia
seen from India

seen from Japan

seen from Canada

seen from Malaysia

seen from Canada
seen from Malaysia
seen from Saudi Arabia

seen from Brazil
seen from India
seen from United States
seen from Australia

seen from United Arab Emirates

seen from Malaysia
seen from India
seen from United States
seen from United States

seen from Italy
seen from United States
@j0shit0
Windows 7: How To Automate Tasks With The Task Scheduler
Solving the problem task scheduler
Hey guys, welcome to let's talk algorithms. This is Venkatesh and today we'll be solving the problem task scheduler. So the problem statement is that, given a list of tasks in term in the form of capital, letters or basically uppercase letters, uppercase characters and a cool of period and the cooler period states that, when you are solving each task after solving each task, basically either you Wait the amount of cool off period or solve other tasks so given these are the conditions, what is the basically written, the least number of intervals? The CPU will take to finish all the given tasks at any point of time.
So, for a unit of time you will you can solve one task or you can just wait so, given these are the conditions, these are the tasks and a given n, which is cool of period. We have to find the least number of unit time units basically which you can use to solve the given task. So the important consideration here is that, after solving each task, you have to wait the value M. In this case the value is 2. So, let's think of a really brute force approach right. What is the worst way you can solve this problem? The worst way you can solve this problem is, you know, solve a certain task, wait two units of time and so all the tasks again right so yeah. This works right. This is this is like real brute force here.
You can just wait one task because you solve one a and one and all right, so this is the most possible way to probably solve this problem. How? Because, after solving it ask you're like waiting until the cooldown period and going to the next task, so as you can see, this is a really safe way to do it, but the other way is basically: let's say you solve a task here right then you can. All tasks being because it's a different task since you solved yay you solved B, so it's one unit of time, but the cool of period is two, so either you have to wait or solve some other task, since we have only task a and B here. We don't have anything else to you, know solve, so you can just wait.
Let'S call W as a wait. I can just are number one, because you don't want to be confused with task W and guess we have one. So we saw a B and then you wait and then you can do the similar thing right so and then you can finally do this. So what is the time taken to solve these tasks and the cool of period? Two is, basically, you see each one. Two three: five six eight. So we took eight units of time to basically solve three years and three betas. So the way we did is we don't understand a pattern here, because the number of tasks between a and B are same. Let'S say the input is something like this yay, the P again and, let's say the full of parodies and is too so. What would you do right, like let's say, do print with like similar approach, as we did above this all yeah you solve B. So you don't have any yes left and you just solve B.
So you have to wait one. You have to wait one more time, because the cool of period is two and then you solve another D. Wait once you wait one more time and then you solve B, so the number of time basically time units you require to solve. This is also eight units. Think if we can optimize this right, how do we optimize this? We can optimize this by, as we know after solving a task, we have to wait n number of units I'd. So, ideally, we should be greedy in the indicate, in the sense that, after solving a certain task, we should make sure that there are make sure that there are enough. You know other tasks to solve, so that so that will minimize the waiting time.
How do we do this? Let'S say instead of you know, when the tasks are ABB instead of tasks, starting with EA less if we start, let's start with B, so after solving we after starting, basically after doing the task B, you do task a and then you wait and then you can Do B again, you wait, wait and then P, as you can see just by doing this following this approach, basically solving the bigger problem. First, we've reduced the time by one unit. So the input is this parrot here, as in you have like three units of B and only one unit of here. That'S why you don't see and and that cool of period is a lot which is basically two related to the size of the input. It'S a lot, so that's a reason. The number of time units here is seven, but let's say you have a really large input of varying kinds, and then you have a time of Peter at certain time of period. Solving the bigger task first always gives you the best case complexity. So that is what the intuition here is that you solve the bigger task, the number of the tasks with which, with largest repetition first and then you solve other tasks and then come back to the largest task again, so let's write the all rhythm for this.
Let'S comment this out so the way we track all the repetition count and everything is that's to encounter int in a counter of since the question mein mentioned that we only have capital letters and then um in the form of tasks. So we can just have a integer array of 26 size, then for each character or basically for each task. What do we do? Is we maintain the repetition here counter of C minus the character J? Basically, it gives you the relative index of a certain task in the counter array, so once we have that, let's sort it right, we we are sorting it, because we want to solve the largest task first and we do have after solving. This is ascending order right. We do we have the largest task now, so the index 25 will have the largest task. So let's declare a variable time, which stores the number of time units we actually require to solve all this thing, so we need an exit condition.
So, while counter of 25, which piece which has the largest number of tasks as I was discussing, the largest value would be at the index 25, so the exit condition is until the largest value is solved right, the until the largest task is solved. We repeat this thing so in each loop. What do we do? Let'S initialize two variables I and J, which is basically the represents the number of tasks we solve in each loop. So while you do that, the I, while I is less than or equal to N and counter of G greater than zero, what do we do so? This is basically we'll try to solve n number of tasks each time right. The N is basically the cool of period, so, while this is true, counter of G reduce the number of tasks at the XJ increase.
The time because we solve one task, the y plus plus, which is basically making sure that we only saw a number of tasks and then the value J J could be if basically J. If J is equal to zero, then we want to move it back to the last index. If it's not, then we want to decrement once so once this is done. So when do we exit this, we exit in this inner loop in two cases, one after solving the number of tasks which is like an or we've solved all tasks. Basically, and then counter of J is zero, so arrays dot sort. So one after we do. This will be sort the in the counter array, and one thing to make sure is basically after solving this, make sure it's beef, it's being sold the whole problem if it's being sold break, otherwise we are going to assign time equal to x, plus and minus.
I plus one, so we do this. Let'S say if we have a scenario where we solve number of basically the task less than the value, and so let's say like in in this scenario right we have solved the only one beat a task we have. So we have to either wait. We basically have to wait and as if we solve the next task, so this is the value we use if left over task is less than, and then we do that so. Finally, after this we will treat than the value time. So, let's run the code. What are we doing here? It'S basically a task all right, so for a given input, the value is 8 and we've got it. Let'S submit it all right, it's run in 7 milliseconds. So the time complexity here is often log n. Where n is the number of total tasks, if you have any questions, please feel feel free to comment on the video and, if you like, the video please subscribe to the channel. Thank you.