chandeepsingh85
BAN USER
- 0of 0 votes
Answers//Online Coding Assignment
As a member of the cab finder app team, you are tasked with implementing a CabFinder class that has the following minimal public interface:class CabFinder implements CabStatusListener { /** * Initiates CabFinder. Called only once per app startup. * @app An application object providing services implemented by * the rest of the application. * @maxCabs Nearest number of cabs that can be returned to the user */ public void initialize(CabApp app, int maxCabs) { //Insert code here... } /** * Gets nearest cabs within 1km of the current user’s location. * These must be the *nearest possible* @maxCabs in the 1km area. * @return An unordered list of the nearest cabs. */ public Cab[] getNearestCabs() { //Insert code here... } /** * Asynchronous Callback per CabStatusListener (see below). Called when the position of a cab has changed. */ void onCabPositionChanged(Cab cab) { //Insert code here… } /** * Asynchronous Callback per CabStatusListener (see below). Called when a cab’s availability changes. * @cab The cab whose availability has changed * @isAvailable true if the cab is now available, false otherwise */ void onCabAvailabilityChanged (Cab cab, boolean isAvailable) { //Insert code here… } }
Supporting Classes:
Here are the classes and utilities that are available for your use (you are not required to write any implementation for these classes)
/**
* Coordinates on a 2D map with a one meter granularity.
*/class Position { public int x; public int y; } interface Cab { /** * Unique identifier of a cab. */ int getID(); /** * Gets the current position of the cab */ Position getCabPosition(); /** * Returns whether or not the cab is available */ boolean isAvailable(); }
/**
- chandeepsingh85 in United States
* Provides services implemented by the rest of the Cab Application.
*/
interface CabApp {
/**
* Gets the current location of the user
*/
Position getUserPosition();
/**
* Returns an iterator that gives access to the list of all cabs in the city
*/
Iterator<Cab> getCabs();
/**
* Registers a CabStatusListener object for change notifications of cab object data.
*/
void register(CabStatusListener listener);
}
/**
* The CabStatusListener interface
*/
interface CabStatusListener {
/**
* Called when the position of a cab has changed.
* @cab The cab object
*/
void onCabPositionChanged(Cab cab);
/**
* Called when a cab’s availability changes.
* @cab The cab object
* @isAvailable true if the cab is available, false otherwise
*
*/
void onCabAvailabilityChanged (Cab cab, boolean isAvailable);
}| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - -1of 5 votes
AnswersFind if 2 lists of rectangle are exactly equal. How would you sort the lists?
- chandeepsingh85 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Graphics - 0of 0 votes
AnswersGiven 2 quad-trees find the intersection of black-pixels.
- chandeepsingh85 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Trees and Graphs - 25of 27 votes
AnswersGiven a large network of computers, each keeping log files of visited urls, find the top ten of the most visited urls.
- chandeepsingh85 in United States
(i.e. have many large <string (url) -> int (visits)> maps, calculate implicitly <string (url) -> int (sum of visits among all distributed maps), and get the top ten in the combined map)
The result list must be exact, and the maps are too large to transmit over the network (especially sending all of them to a central server or using MapReduce directly, is not allowed)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - -2of 2 votes
AnswersGiven a class of block reader, read in unlimited string flow.
- chandeepsingh85 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer String Manipulation - 2of 2 votes
AnswersYou are given a grid, with points on the intersections (think a map of streets, people are standing on random corners). Write code to calculate the point on the grid that is the shortest distance from every point on the grid.
- chandeepsingh85 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Trees and Graphs - 2of 2 votes
AnswersGiven a set top box:
- chandeepsingh85 in United States
a, b, c, d, e,
f, g, h, i, j,
k, l, m, n, o
p, q, r, s, t
u, v, w, x, y
z
Write code to give the character sequence given a word, For example, if the word is "CON", the function will print this:
Right//now we're at B
Right//now we're at C
OK//to select C
Down
DOwn
Right
Right
OK//to select O
Left//now at N
OK//to select N
note: Be careful when you're at Z. if you go to the right, you will get stuck.
Afterwards, the interviewer adds a space to the right of 'Z' to test the code.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Site Reliability Engineer String Manipulation Algorithm - 0of 0 votes
AnswersDesign and implement a class, which returns a random string value from a set with an arbitrary probability distribution given by an array of probabilities. Using an existing random number generator with a uniform distribution(e.g., Random.nextFloat()), you return the string for the random float value based on the strings probability distribution.
- chandeepsingh85 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Probability
Sorry people, I am unclear about this. Could you please provide a running code?
- chandeepsingh85 October 28, 2013there are n rectangles in one list and m in the other. No idea how to proceed with this. Any suggestions with code?
- chandeepsingh85 October 22, 2013Could you tell me why the most frequent element 6 in your output has frequency 3? 6 appears 7 times.
- chandeepsingh85 October 20, 2013It works!
However instead 64, it should be 65, else the Z doesn't appear in the latter combinations.
oh, any suggestions on how to solve?
- chandeepsingh85 September 25, 2013Could someone provide a better solution than this (O(n^3)) ?
- chandeepsingh85 September 25, 2013public class Excel {
public static char column(int n) {
int d, r;
int A = 'A';
int Z = 'Z';
int numLetters = Z - A + 1;
char s = ' ';
while (n > 0) {
d = (n - 1) / numLetters;
r = (n - 1) % numLetters;
s += A + r;
n = d;
}
return Character.toUpperCase(s);
}
public static void main(String[] args) {
for (int i = 1; i <= 26; i++) {
System.out.println(column(i));
}
for (int i = 1; i <= 26; i++)
for (int j = 1; j <= 26; j++)
System.out.println(column(i) + "" + column(j));
for (int i = 1; i <= 26; i++)
for (int j = 1; j <= 26; j++)
for (int k = 1; k <= 26; k++)
System.out.println(column(i) + "" + column(j) + ""
+ column(k));
}
}
I am kind of confused about how this.maxCabs = maxCabs; is being used. Could you kindly provide a little explanation? And also if possible some test cases. That would be of great help. Thanks
- chandeepsingh85 January 08, 2014