anon123
BAN USER 0of 0 votes
AnswersFind the smallest window in a string containing all characters of another string
 anon123 in United States Report Duplicate  Flag  PURGE
Algorithm  0of 0 votes
Answersgiven a set of n meetings and m meeting rooms, how will you schedule the meetings in the meeting rooms?
 anon123 in United States Report Duplicate  Flag  PURGE
Algorithm  0of 0 votes
AnswersGiven a linked list like a1a2a3a4b1b2b3b4. Convert it into a1b1a2b2a3b3a4b4.
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon Algorithm  0of 0 votes
AnswersGiven array of N integers ranging from 0 to N1. Output maximum repeating integer. Use only O(1) memory.
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon Algorithm  0of 0 votes
AnswersRotate a 2D Matrix by 90 degrees
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon  0of 0 votes
AnswersPrint all the cycles in a directed graph
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon  0of 0 votes
AnswersGiven n, find the smallest number for which product of the digits is n, if no such number exists, print 1
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon  0of 0 votes
AnswersWrite a routine to reverse every k nodes in a given linked list
 anon123 in United States
input : 1,2,3,4,5,6 k:3
output : 3,2,1,6,5,4 Report Duplicate  Flag  PURGE
Amazon  0of 0 votes
AnswersFind all nodes that are at a distance k from leaf nodes
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon SDE1 Algorithm  0of 0 votes
AnswersGive some practical applications of binary search trees
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon  1of 1 vote
Answersgiven a bst, find the inorder successor of a given node. th nodes dont have a pointer to parent
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon  0of 0 votes
AnswersGiven three strings s1, s2 and s3. Check whether s3 is an interleaving of s1 and s2
 anon123 in United States Report Duplicate  Flag  PURGE
 0of 0 votes
AnswersOne can serialize a BST by storing its inorder plus one of preorder or postorder notations. what makes inorder mandatory?
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon  0of 0 votes
AnswersGiven a tree, generate all paths. Note : all paths..not just the ones starting from root
 anon123 in United States Report Duplicate  Flag  PURGE
Amazon SDE1  0of 0 votes
AnswersInput : a1,a2,...,an, b1, b2, ..., bn
 anon123 in United States
Transform it to a1, b1, a2, b2, .... an, bn.
It has to be done inplace Report Duplicate  Flag  PURGE
the question effectively requires us to find that particular subset for which difference between sum of its elements and that of the elements in its compliment is minimal. every one of the subsets will have to be examined. IMO, this will be O(2^n).
void f(int[] a, int i, int[] b, int[] c, int r, int[] B, int[] C)
{
if(i==a.length)
{
int diff = abs(sum(b)  sum(c));
if(diff < r)
{
r = diff
B = b;
C = c;
}
}
f(a, i+1, b+a[i], c, r, B, C);
f(a, i+1, b, c+a[i], r, B, C);
}
while calling, pass infinity for r

anon123
May 25, 2014 maintain the following attributes for each of the node u, d denoting number of uphill and downhill edges involved in shortest path to the node. initialize them to zero.
invariant to be maintained : at any given point in time, both u and d cannot be >1 simultaneously.
when considering an edge to be added to the SPT, check whether updating u and d values for the destinaion edge would violate the above invariant. an edge can be added only when the invariant is maintained.
node getBST(int[] a, int start, int end)
{
if(start>end)
return null
node x = new node(a[start]);
int i=0;
for(i=start+1;i<end;i++)
{
if(a[i]>a[start])
break
}
x.left = getBST(a, start+1, i1);
x.right = getBST(a, i, end);
return x;
}
getBST(a, 0, a.length1)

anon123
February 11, 2014 really depends on implementation of trie. the classic trie implementation which has a slot for ever possible character in the language at each node would be wasteful of memory. if you design your trie such that each node has a pointer only for characters of strings it stores, it should be fine.
share your thoughts.
pseudocode:
bt(current, target, num_moves, min_so_far)
{
if(current==target)
{
if(num_moves<min_so_far)
min_so_far = num_moves
return min_so_far
}
if(num_moves>min_so_far)
return min_so_far
candidates = get_candidates(current)
foreach(candidate in candidates)
{
min_so_far = bt(candidate, target, num_moves+1, min_so_far)
}
return min_so_far
}

anon123
January 17, 2014 input needed :
1. what is the length of the appointment to be scheduled?
2. What is the last time until which an appointment can be scheduled?
once we have these details, follow these steps:
1. arrange already scheduled appointments in increasing order of start time. O(nlogn)
2. traverse through the list and compute difference between end time and start of successive intervals.
3. an appointment can be scheduled if oneo f the following is satisifed:
a) if the gap between any two successive appointments is greater than or equal to the length of the required appointment
b) if there is enough time left in the day after last appointment to accomodate the new appointment
Repmariacbrister, Graphics Programmer at Graphic Systems
Hey, I am Maria and I am from Bluefield. Currently, I work as a freelancer graphic artist. From an early ...
Repbrandysolsen, Area Sales Manager at AMD
I am a Social butterflies who enjoy travel.Have fun doing this job and project an atmosphere that reflects Amazon ...
Open Chat in New Window
all you need is a binary indexed tree aka fenwick tree
 anon123 February 22, 2015