jimmy514in
BAN USER- 0of 0 votes
AnswersGiven the fact that you have a map <SessionId, SessionValueObject> , . The sessionValueObject contains timestamp as well associated with the session. In generality, we are maintaining a key value pair. And each session has a timestamp associated with it.
- jimmy514in in United States
Now the question was given a particular timestamp associated with a sessionValueObject, we need to implement a data structure such that,
given a timestamp t1, we need to free/ remove all the sessionValueObjects associated after the timestamp t1.
How do we do this efficiently?| Report Duplicate | Flag | PURGE
Bank of America Java Developer - 0of 0 votes
AnswersGiven a Directed graph, and a source point say S, and say C is the most distant node from S, you need to find the route from S to C . Suppose ,for example there is a path from A-> B- >C, and a path from A->B->D->C, here the most distant node is C with path length as 4. Also, each edge has unit length. Since the graph is directed , you need to implement an algo which takes care of the cycles in the graph. How would you implement this?
- jimmy514in in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven a double ended queue with front and rear as two pointers, if a two people play a game. Say removal of number from a given list- from either side of the list. given the fact that the players can view the list of numbers, maximize the chance of each player winning?
- jimmy514in in United States
I was thinking more in terms of minmax tree/ alpha beta pruning. Any suggestions on this?
Any suggestions?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - -1of 1 vote
AnswersGiven a file using regex find all the ip address ina text file.
- jimmy514in in India| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer - 0of 0 votes
AnswersDifference betwen Aggregation and composition. What is enum. Write a design pattern except singleton. Write binary search. Write recursive binary search. Elaborate on man in middle attack. How you create a branch - why in svn? . Explain the architecture of your previous work experience. explain thread concept of synchronization.
- jimmy514in in India| Report Duplicate | Flag | PURGE
RoviCorp Java Developer - 0of 0 votes
AnswersEach time a visitor requests a page from our website, our webserver writes a log entry recoding the visitor's identity and the kind of page requested. Entries are written in chronological order to a plain-text file, with one entry per line. The format of each entry is:
- jimmy514in in United States
user-id page-type-id
User IDs are arbitrary strings that uniquely represent a given user; if a user visits multiple pages, each log entry will have the same user ID. Page type IDs are arbitrary strings that uniquely represent a given kind of page on our site, such as the homepage, a product detail pages, or the shopping cart. Tons of users visit our website, but there are only a few dozen types of pages.
We can use our weblogs to answer questions about user behavior. One interesting question is: what is the most common three page sequence through the site? E.g., if the most common pattern is to buy items advertised on the home page of the site, we might see the most common three page sequence as "Homepage -> ProductDetailPage -> ShoppingCart". However, if customers spend a lot of time browsing the "Customers who bought this item also bought" feature, we might see the most common three page sequence as "ProductDetailPage -> ProductDetailPage -> ProductDetailPage".
Attached is a sample log file for your reference. Within the first 10 lines of the sample, customer "234" travels through the sequences "Listmania -> ProductDetail -> Checkout" and "ProductDetail -> Checkout -> HomePage" once each.
For the sake of this test feel free to assume that everything will fit in memory. Do keep in mind that given the size of our data sets, performance has to be considered, also, we will be looking at more than just correct output..| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Coding Java
The array is not sorted, they can remove the number from either ends of the dequeue. But this is done in an alternative fashion , starting with the first user.
If there are two users A, B . First A picks any number either from front;/ rear . And then B picks. And then A.. till the queue becomes empty!
Its a double ended queue, so they can remove from either ends of the queue.
- jimmy514in March 25, 2013After each user plays the game- removal of a number from the list, the sum is collected for each user, as he proceeds in the game. After all the turns, the sum for each user is noted, and whichever is higher wins the game!
- jimmy514in March 25, 2013What about QuadTree using a map as internal storage element??
private class QuadNode < Value extends Object>
{
QuadNode [] quad ;
Map < String, Value> map;
QuadNode (String key, Value value)
{
if(key== null || value == null)
throw new NullPointerException();
if(quad== null)
quad = new QuadNode[4];
if(map== null)
{
map = new HashMap<>();
map.put(key, value);
}
}
The token for the car can be generated using base4?
So if you have 1 million points, you can first put a few in the map, say if the threshold is 500.
and then split it in 4 quadrants. Time complexity O(n)
Also, you can generate the token id using base 4 , which maps to quadnodes[i] inside the data structure?
Any opinions on that??
lets say n is the element to be searched.
using int binarySearch(a[], n) --> you get the index for n in array a
now use the same binarysearch to find binarySearch(a[] , b[0]);
firstindex - second index
or first index+ secondindex
depending on location whether right or left of the middle elemen.
.. to get answer
Now all you need is to find modulo size for the binary search to get the rotation factor..
anyone played with java enums to create singleton? / or used serialization or reflection API to break it?? any comments on this?
- jimmy514in March 17, 2013interesting read;
introcs.cs.princeton.edu / java/ 23recursion/ GrayCode.java.html
Something very interesting i came across:
wisc-online.com/ Objects/ ViewObject.aspx? ID=IAU8307
You could download the sample log file at:
db.tt / LobF70Rt
Observer on the list of persons in the waiting list..
Observer design pattern with event trigger on the person who adds..
geeksforgeeks . org /the-celebrity-problem/
- jimmy514in March 11, 2013just exploring this idea:
create a bst, with meeting as the node..
if the root of the meeting is null, and you have one meeting, create a root = new meeting()
make pointer ptr = root;
now, if you have a list of meetings,
for each meeting mi, there is a arrival time a_i,
and departure d_i
if( a_i is between ptr.arrival_time and ptr.departure time)
return
if( a_i> ptr.departure_time) ptr=ptr-> right;
if(d_i< ptr.arrival_time) ptr= ptr->left;
}// loop through all the meetings..
and construct a binary tree..
let me know what you think on this?
How about building a trie for the words in the dictionary,
and then using a BFS to pattern match each letter in the matrix ...??
Any comments on this?
This is a clear implementation of the problem.. self explanatory and beautifully written. Thank you!!
- jimmy514in March 08, 2013a simple idea:
if s1< s2 where s1 and s2 are two strings..
int hashcode = s1.hashcode();
for(int i=0;i<s2.length-s1.length;i++)
{
// get the hashcode of the second substring with length of s1..
// and compare.. if it matches, we get first occurance..
// and return the index;
}
output can also be 1,3,7,10...wat about that?
- jimmy514in August 23, 2011So wat happens when we get the following sequence?
{ 1 2 -2 1 2 -4 5 -1}
So going thru the code, whats the o/p??? we make the index 0 when we reach a -ve number right?
Isnt there a better algo than DFS?
- jimmy514in March 30, 2013