@Rashmi: I did not get your approach. I do not get emails from the group
just in case you have posted a solution :( What do you mean by keeping a
count? Also, are you using a hashmap? If yes, whats ur K,V?
#Pralay
On Tue, Feb 12, 2013 at 10:00 AM, rashmi i rash...@gmail.com wrote:
Hey Pralay,
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
I guess the part 1 can be solved in O(n) time and space both. Here is my
approach.
Assume: Array given is arr[] = {2,3,1,2,3,2,4,1,5,6}
1. Given an array, scan thru it, element by element and hash it on a
hashmap with key as the arr[i] as the key and i+1 as the index.
2. There would be two cases
Also, for the part two of the question, you can simply go in for the *kth
largest positive index *in the same hashmap (described earlier for part 1).
That solves the part two of the problem :)
Hth,
*Pralay Biswas*
*MS,Comp Sci, *
*University of California, Irvine*
On Tue, Feb 5, 2013 at 8:46 PM
Technically linear!
On Mon, Nov 26, 2012 at 9:47 PM, shady sinv...@gmail.com wrote:
what is the time complexity of this?
str_reverse(str){
if(isempty(str)) return str;
else if(length(str) = even) then split str into str_1 and str_2; (of
equal length) (Calculate mid =O(1), then
Yes, my bad. I din notice the recursion at all! Thot it to be a flat
mid-split followed by a reverse followed by a concat. Thanks.
On Mon, Nov 26, 2012 at 11:18 PM, atul anand atul.87fri...@gmail.comwrote:
considering '+' , here will take Cn time . Here '+' is for concatenate ,
now this
for two way
sequential access, good for insertions in the middle.
Pralay Biswas
MS-CS, University of California Irvine
On Wed, Nov 21, 2012 at 6:51 AM, shady sinv...@gmail.com wrote:
which data structure among the follow has fastest sequential access ?
i) vector
ii) Singly linked list
iii
I am sorry, vectors are synced and hence slow (concurrency overhead,
arraylists are non synced). Rest remain the same, if your application
demands frequent two way sequential scans, go for DLL.
Pralay Biswas
MS-CS, University of California Irvine
On Wed, Nov 21, 2012 at 6:57 AM, Pralay Biswas
Also, vectors are not contiguously memory slotted always. Its a expanding
array where the resizing takes place on demand. There are times when the
array backing the vector is resized and re-allocated, but even then the
amortized cost of insertion stays linear (O(n)). Although it makes sense
to
@Dave: Could you please correct me if am wrong here.
1) So we are looking out for the worst case, and that happens when m and n
are consecutive Fibo numbers, being mutually prime to reach other.
2) Its taking 5 iterations to reduce the number of digits in the smaller of
m and n, by one. Assuming
is the significance of while loop in the above code?
I understand that the for loop implies O(n),does the log n in the O(n log
n) comes from the while loop?
What if there where two while loops in the for loop separately?
On Sat, Oct 27, 2012 at 3:26 AM, Pralay Biswas
pralaybiswas2...@gmail.com wrote
Yes!
On Fri, Oct 26, 2012 at 2:55 PM, rahul sharma rahul23111...@gmail.comwrote:
for k=1 to n
{
j=k;
while(j0)
j=j/2;
}
the complexity is big o is o(nlogn)
am i ryt
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
@Piyush: Try this i/p 8,0,0 ; 2,6,0-- Ur algo aint adequate..
On Sat, May 19, 2012 at 11:24 PM, Piyush Khandelwal
piyushkhandelwal...@gmail.com wrote:
Hiii!! I have some idea about the solution. Please notify me if i am
wrong
a= [ 4,3,5 ] and b= [ 3,5,4 ]
diff=0;
for (i=0; in;i++)
Nice solution Akshay.
Here is my small attempt!
[image: Inline image 1]
#Pralay
On Mon, May 7, 2012 at 1:03 AM, Akshay Rastogi akr...@gmail.com wrote:
private static void swap(char[] str, int i,int j) {
char temp = str[i];
str[i] = str[j];
str[j] = temp;
}
14 matches
Mail list logo