Guys,
Why can't we simply use a hashset for both the questions. hash the arr[i]
and the frequencies in the hash map in the first pass. Then iterate over
the array to find the first arr[i] whose freq is 1 in the hash map. For
second part, keep a count and find the kth element in the array whose
first problem can be solved using a fixed sized array if we know the
range of numbers or a hash table with an appropriate hash function and
it is O(N) for time and space as some solutions above already
mentioned this.
for the second problem, I don't think heap is the right data structure
which is
One solution for the 2nd question can be LinkedHashMap (linked list +
hashmap) .
Store the integer in linked list in the order of occurrence in stream and
make an entry in hashmap on first occurence. Delete the integer entry from
linked list on 2nd occurence and replace the reference with some
*What are the applications of threaded binary Trees apart from morris
traversal ?*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
Hi All,
I need ur help in solving few questions.
Would you please help me out *BY GIVING THE ALGORITHM AND THE LOGIC BEHIND
IT and it's DEEP EXPLANATION IF POSSIBLE?*
*
*
*a. Kadane’s Algo.*
*
*
*b. Linked-list intersection point.*
*
[A tree with only parent pointer, how to find LCA?]
*
*
can use counting sort
On Sun, Jul 15, 2012 at 6:37 PM, santosh thota santoshthot...@gmail.comwrote:
If we can retrieve ith prime efficiently, we can do the following...
1.maintain a prod=1, start from 1st element, say a[0]=n find n th prime
2.check if (prod% (ith_prime * ith_prime )==0) then
Hey Pralay,
Sorry, if I have missed any point.Why would we need to map the
frequencies when the second problem can be solved by simply keeping a count
and comparing the index values that have been already mapped.
On Fri, Feb 8, 2013 at 11:19 AM, sourabh jain wsour...@gmail.com wrote:
One
Hi,
I've just learned about the water crisis and would be grateful if you could
spend a few minutes to help solve it:
https://waterforward.charitywater.org/GSkEnwJl
Thanks,
Manikanta
--
the charity: water team
WaterForward, 387 Tehama Street, San Francisco, CA 94103, USA.
Click here to