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.03. Find the Smallest Common Number.html -- 1.7 meg
Find the Smallest Common Number - Coderust: Hacking the Coding Interview
We’re given three integer arrays, each sorted in ascending order. Return the smallest number common in all three arrays. In case no number is common, return -1.
The arrays are sorted in ascending order. We will use three iterators simultaneously to traverse each of the arrays. We can start traversing each array from the 0th0^{th}0th index, which always has the smallest value.
If the values pointed to by the three iterators are equal, that is the solution. Since the arrays are sorted in ascending order, that value must be the smallest value present in all of the arrays.
Otherwise, we see which of the three iterators points to the smallest value and increment that iterator so that it points to the next index.
If any of the three iterators reaches the end of the array before we find the common number, we return -1.
Let’s visualize the step by step implementation of the solution described above.
Created with Fabric.js 3.6.667102530636404567850161014Iterators pointing towards 0th index of all the arrays.But the values of arrays at 0th index are not the same.
1 of 8
Created with Fabric.js 3.6.667102530636404567850161014Since the values at 0th index aren't same. We look at the smallest value amongst the three arrays at 0th index, which is 0, so we increment the iterator of second array.
1 of 8
Created with Fabric.js 3.6.667102530636404567850161014Again, all three values at the current indices being pointed at by the iterators are not equal.
1 of 8
Created with Fabric.js 3.6.6We looked at the smallest value, which is 1. So, we increment the iterator of third array.67102530636404567850161014
1 of 8
Created with Fabric.js 3.6.667102530636404567850161014We looked at the smallest value, which is 4. So, we increment the iterator of second array.
1 of 8
Let’s take a look at the solution code below:
C++
Java
Python
JS
Ruby
Go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<vector>
#include<string>
usingnamespace std;
int FindLeastCommonNumber(vector<int>& arr1, vector<int>& arr2,
vector<int>& arr3){
// Initialize starting indexes for arr1, arr2 and arr3
int i =0, j =0, k =0;
while(i < arr1.size()&& j < arr2.size()&& k < arr3.size()){
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.