To make sure your calendar, event reminders, and other features are always
correct, please tell us your time zone (and other details) using the
drop-down menus below:
Set Date/Time format:
In 12 Hour format the hours will be displayed as 1 through 12 with “a.m.” and “p.m.”
displayed after the time (ex. 1:00p.m.). In 24 hour format the hours will be displayed as 00 through 23 (ex. 13:00).
You can always change your time zone by going to your Account Settings.
Use the dropdown menu to view the events in another time zone. The primary time zone will be displayed in parentheses.
Use the dropdown menu to view the events in another time zone. The primary time zone will be displayed in parentheses.
Visiting Rany Milton(username: itsrandy)
Tag
Please wait...
Select a Color
Manage Applications
Check the items that you want displayed. Uncheck all to hide the section.
Calendars
Files
Addresses
To Dos
Discussions
Photos
Bookmarks
The “Switch Navigator” button will no longer be available after February 14, 2017.
Please learn more about how to use the new Navigator by clicking this link.
01.DS.02.01. Find Maximum in Sliding Window.html -- 1.7 meg
Find Maximum in Sliding Window - Coderust: Hacking the Coding Interview
The algorithm uses the deque data structure to find the maximum in a window. A deque is a double-ended queue where the push and pop operations work in O(1)O(1)O(1) at both ends. It acts as our window. The deque stores elements in decreasing order. The front of the deque contains the index for the maximum value in that particular window.
At the start of the algorithm, we search for the maximum value in the first window. The first element’s index is pushed to the front of the deque.
If the current element is smaller than the one whose index is at the back of the deque, then its index is pushed in and becomes the new back.
If the current element is larger than that of the element at the back of the deque, then the back of the deque is popped repeatedly until we find a higher value. Then we push the index of the current element in as the new back.
We will repeat the following steps each time our window moves to the right:
Remove the indices of all elements from the back of the deque, which are smaller than or equal to the current element.
If the element no longer falls in the current window, remove the index of the element from the front.
Push the current element index at the back of the window.
Let’s visualize an example with a window size equal to 333 on an array.
Created with Fabric.js 3.6.6-42-51-16windowresultThis is the initial state. Our window deque and our results array are bothempty. Our window size 'w' is 3.
1 of 7
Created with Fabric.js 3.6.6-42-51-16window0resultIn the first iteration, we add 0 to the window deque. The window dequestores the indexes of the array. It will store larger elements at the frontand smaller elements at the back.
1 of 7
Created with Fabric.js 3.6.6-42-51-16window1resultIndex 0 is removed from the window deque as its value i.e. array[0]= -4 is less than array[1] = 2. So, index 1 is added at the back of the deque. The back is currently the front as well.
1 of 7
Created with Fabric.js 3.6.6-42-51-16window12result2Index 2 is pushed to the back of the deque after index 1. At this point we are done with first 'w' elements. We will push the max of these 'w' elements intoour result array.
1 of 7
Created with Fabric.js 3.6.6-42-51-16window13result22When the window slides one step to the right, we see that the element atarray[3] = 1, is greater than array[2] = -5. So index 2 is removed from thewindow and 3 is added to the back. Max is still index 1, i.e., array[1] = 2.
Attach this document to an event, task, or address
You can attach a link to this document to an event in your Calendar, a task in your To Do list or an Address. Check the boxes below for the data you want to
bring into the event’s or task’s description, and then click “Select text to copy” to have the next event or task you create or edit have the document text and link.