This was also asked in my Yahoo! Interview this year. :)
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Fri, May 14, 2010 at 10:10 AM, Rohit Saraf
wrote:
> ex
exactly ..
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Fri, May 14, 2010 at 10:07 AM, vignesh radhakrishnan <
rvignesh1...@gmail.com> wrote:
> This is for
This is for kth largest. Change it for kth smallest
In fact, this problem is amenable to something very similar to binary
search. Suppose my arrays are A and B. The idea is to keep track of two
indices, a (for A) and b (for B), such that a + b = k - 1 (it's very
important to maintain this invarian
cant u use a hash map of O(K) where K is distinct elements in
string..
On Thu, May 13, 2010 at 8:13 PM, jalaj jaiswal wrote:
> input a character array from the user and output in the following way.
> example string is amazon.. then output should be a2m1z1o1n1
>
> i did it taking a 26 siz
Using BFS we can do it.
Thanks,
Sathaiah
On Thu, May 13, 2010 at 6:48 PM, Dave wrote:
> Do a post-order traversal, keeping track of the level in the tree. As
> you visit each node, remove it from the tree and add it to the spike.
> Use the left pointer to point to the next level, and the right
input a character array from the user and output in the following way.
example string is amazon.. then output should be a2m1z1o1n1
i did it taking a 26 size array... some better solution ??
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You received this message becau
can some1 post the solution here..the link by dufus is not working and i'm
not able to find any other relevant link to this problem.
On Sat, Sep 19, 2009 at 1:44 PM, ankur aggarwal wrote:
> thanxs dufus.
> got the soln
>
> On Fri, Sep 18, 2009 at 8:20 PM, Dufus wrote:
>
>>
>>
>> Hey
This can be done with level order traversal of the tree
Algorithm
count = count2 = 0
1. Push the root in the queue.
2. keep count at each level for root count =1
3. while(queue not empty)
4. push all childs of node at the top of queue in queue
5. count2 += (number of childs of node at t
Use Breadth First search ..
CHERUVU JAANU REDDY
M.Tech in CSIS
On Thu, May 13, 2010 at 9:18 AM, vinayan c wrote:
> 2->
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, se
use BFS traversal method
-- Prashant Kulkarni
|| Lokaha Samastaha Sukhino Bhavanthu ||
|| Sarve Jana Sukhino Bhavanthu ||
On Wed, May 12, 2010 at 8:48 PM, vinayan c wrote:
> Something like this
>1
>2 3
> 4 5 6
given a bst... find two nodes whose sum is equal to a number k ... in O(n)
time and constant space...
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this grou
array and linked list are not the same so all solutions based on array
are wrong.
think this way : how to print(or append in a linked list) the binary
search tree in the sorted order -- the answer is in-order traversal.
you need to do opposite of it here.
On May 12, 10:17 am, divya jain wrote:
You are given two sorted lists of size m and n. Give an O(log m+log n)
time algorithm for computing the kth smallest element in the union of
the two lists
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to al
do bfs.
On 13 May 2010 09:18, vinayan c wrote:
> Something like this
>1
>2 3
> 4 5 67
>
>
> 1
> |
> 2->3
> |
> 4->5->6->7
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this messa
use bfs.
On Thu, May 13, 2010 at 9:18 AM, vinayan c wrote:
> Something like this
>1
>2 3
> 4 5 67
>
>
> 1
> |
> 2->3
> |
> 4->5->6->7
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You receive
This problem was asked in google phone interview. We have N element
array with k distinct keys(No relation between k & N given so assume
khttp://groups.google.com/group/algogeeks?hl=en.
the best approach to it is to build a balanced tree from bottom to up rather
than top to bottom.
On 12 May 2010 22:47, divya jain wrote:
> thanks a lot to all for their replies..
>
>
> On 9 May 2010 11:23, rahul rai wrote:
>
>> can anyone give me links to more educative and active groups like
>
Do a breadth first search on the tree and link all nodes at the same
level in the order that you process them
--Anurag
On Thu, May 13, 2010 at 9:18 AM, vinayan c wrote:
> Something like this
> 1
> 2 3
> 4 5 6 7
>
>
>
it looks like left child right sibling relation ??? isn't it ?
On Thu, May 13, 2010 at 9:18 AM, vinayan c wrote:
> Something like this
>1
>2 3
> 4 5 67
>
>
> 1
> |
> 2->3
> |
> 4->5->6->7
>
>
>
>
>
>
>
>
>
>
do the levels need to be linked?? either case... the approach should be
use BFS to get the elements by level and then link them
On Thu, May 13, 2010 at 9:18 AM, vinayan c wrote:
> Something like this
>1
>2 3
> 4 5 6
Do a post-order traversal, keeping track of the level in the tree. As
you visit each node, remove it from the tree and add it to the spike.
Use the left pointer to point to the next level, and the right tree
pointer for each level of the spike. If you visit the right subtrees
before the left subtre
Something like this
1
2 3
4 5 67
1
|
2->3
|
4->5->6->7
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group
python int has no bounds, it can scale upto the mem u have available on your
computer.
On Thu, May 13, 2010 at 7:53 AM, Nikhil Agarwal
wrote:
> @jitendra: your python code is awesome and it works.:)
>
>
> On Wed, May 12, 2010 at 6:37 PM, divya jain wrote:
>
>> thanx to all 4 the solutions..
>>
>>
23 matches
Mail list logo