Re: [algogeeks] Re: search in O(logn)

2012-06-09 Thread partha sarathi Mohanty
it is rotated to get 14-1 O(log(n)) how can you find rotation point in log(n) ? On Fri, Jun 8, 2012 at 6:57 PM, partha sarathi Mohanty partha.mohanty2...@gmail.com wrote: It is easy.. find the point where it is rotated to get 14-1 O(log(n)) since 214 that means u have to find

Re: [algogeeks] first Repeating character in a string

2012-06-08 Thread partha sarathi Mohanty
@saurabh: why would u count all??? just see while counting if the bitmap is set.. then return the char. On Fri, Jun 8, 2012 at 4:33 PM, Saurabh Yadav saurabh...@gmail.com wrote: order of hashing and counting is important eg. abba if we do hashing by characters 'a' is stored before 'b' and

Re: [algogeeks] Re: search in O(logn)

2012-06-08 Thread partha sarathi Mohanty
It is easy.. find the point where it is rotated to get 14-1 O(log(n)) since 214 that means u have to find it in subarray [123].. do a binary search here o(long(n)) final 2*O(log(n))... On Fri, Jun 8, 2012 at 7:44 PM, Dave dave_and_da...@juno.com wrote: @Hassan: This is not possible without

Re: [algogeeks] Re: interview HARD problem

2012-06-05 Thread partha sarathi Mohanty
no if ta/om/to/am/ba/batot/amoma are words then it should be the one. no 5*2 3*3 On Tue, Jun 5, 2012 at 7:45 PM, Gene gene.ress...@gmail.com wrote: Does this sufficae? Suppose you were using a dictionary from the frapplewonk language, which has only 5 words: tab oma to am ba

Re: [algogeeks] Google Q : all anagrams next to each other

2012-05-23 Thread partha sarathi Mohanty
@ashish : couldnt get u.. can u give an example?? On Tue, May 22, 2012 at 5:45 PM, Prem Krishna Chettri hprem...@gmail.comwrote: What I Could possibly think of is For each string S1 that is an anagram of some string S, use Map and Store the Key Value as (S1,S). Now there is a trick here abt

Re: [algogeeks] amazon

2012-05-23 Thread partha sarathi Mohanty
Java has something call treeMap. it stores strings lexographically.. u can always do permutations and store them in a treeMap. and get the rank then... just the idea.. will post the solution once i am done.. what do u guys think.abt the idea??? On Tue, May 22, 2012 at 9:46 AM, atul anand

Re: [algogeeks] symmetric binary tree

2012-05-23 Thread partha sarathi Mohanty
recurse on left and right will do it and keep comparing the values On Tue, May 22, 2012 at 2:50 PM, atul anand atul.87fri...@gmail.com wrote: no need of creating another mirror tree you just need to call the function func(root-left,root-right); now left sub tree and right sub tree will be

Re: [algogeeks] amazon

2012-05-23 Thread partha sarathi Mohanty
); permute(st + chars.charAt(i), newString); } catch (Exception e) { e.printStackTrace(); } } } } On Tue, May 22, 2012 at 2:19 PM, partha sarathi Mohanty partha.mohanty2...@gmail.com wrote

Re: [algogeeks] Re: Microsoft interview question

2012-05-21 Thread partha sarathi Mohanty
@ashish.. it wont be constant space then.. surely it will be o(n) though On Mon, May 21, 2012 at 7:23 PM, Ashish Goel ashg...@gmail.com wrote: Dave, Cant we have a hash table with the item as key and its count as value (walk over array A and build HT). For permutation check, walk over

Re: [algogeeks] Re: Microsoft interview question

2012-05-21 Thread partha sarathi Mohanty
a[] = [-1,-3,4,0,7,0,36,2,-3] b[] = [0,0,6,2,-1,9,28,1,6] b1[] = [0,7,0,36,4,-6,3,0,0] b2[] =[-1,-3,11,0,0,0,35,0,0] suma = 42 proda = -84*72*3 sumb = 51 prodb = -84*72*3 sumb1 = 44 prodb1 = -84*72*3 sumb2 = 42 prodb2 = 33*35 do the sum and prod operation w/o 0s and compare the values..