> --
> Rohit Jangid
> http://rohitjangid.com
> Graduate
> Deptt. of Computer Engineering
> NSIT, Delhi University, India
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group
@atul: Well yes this might help, thanks :)
On Tue, Mar 6, 2012 at 4:24 PM, atul anand wrote:
> hope this will help you :-
>
> http://www.algorithmist.com/index.php/Longest_Increasing_Subsequence.cpp
>
> On Tue, Mar 6, 2012 at 3:26 PM, ankur wrote:
>
>> Did any one
Did any one implement this in nlogn ??
Reference: http://en.wikipedia.org/wiki/Longest_increasing_subsequence
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from
ow;
> head=ptr;
> }
> ptr->next->next=follow;
> if(follow!=NULL)
> follow->next->next=NULL;
> }
>
> @ankur: if odd number of nodes then maybe just ask interviewer how he
> wants it to be and try including that case ;)
>
>
> }
>
> On Mon, Jan 2
wat if u have odd no of nodes
On Tue, Jan 24, 2012 at 12:00 AM, atul anand wrote:
> one simple way would be using stacks.
> push node,node->next;
> then pop() , and reversing the pointers.
>
> On Mon, Jan 23, 2012 at 11:46 PM, Ankur Garg wrote:
>
>> Say LL is
&
Say LL is
1->2->3->4->5->6->7->8
Then u need to return
7->8->5->6->3->4->1->2
U cant swap the values U have to rearrange the ptr...
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googleg
Hello
I was going through this link
http://www.geeksforgeeks.org/archives/3187
Wonder what is the time complexity for this..?Can anyone explain >
Regards
Ankur
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to thi
XOR Linked Lists
On Sat, Jan 14, 2012 at 7:06 PM, Ashish Goel wrote:
> design a linked list that has only one pointer per node yet can be
> traversed in forward or reverse direction.
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
@Himanshu
Nice idea..that shud do..but how do we code that ?
regards
Ankur
On Sat, Jan 14, 2012 at 2:23 PM, payal gupta wrote:
> @himanshu thnx..:)
>
> Regards,
> PAYAL GUPTA,
> 3rd YR ,CSE,
> NIT-BHOPAL.
>
>
> On Fri, Jan 13, 2012 at 9:42 PM, Himanshu Neema <
&g
How to do this
Write a function to reverse a UTF-8 encoded string in-place ??
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
alg
...(Recursive)
Do you think it will be possible this way ?
Please correct me in case I got things wrong here
regards
Ankur
On Wed, Jan 11, 2012 at 5:07 PM, atul anand wrote:
> i have little doubt in complexity of proposed algo..
> aren't we including complexity of heapifyin
If we use K merge I think the time complexity would be nm lognm
I think we must try doing in O(m*n)
On Wed, Jan 11, 2012 at 1:54 PM, Ankur Garg wrote:
> @Shady Rows are already sorted ...
>
>
> On Wed, Jan 11, 2012 at 1:53 PM, shady wrote:
>
>> ^^ true, sort the rows a
@Shady Rows are already sorted ...
On Wed, Jan 11, 2012 at 1:53 PM, shady wrote:
> ^^ true, sort the rows and then a K-way merge.
>
>
> On Wed, Jan 11, 2012 at 1:00 PM, Sanjay Rajpal wrote:
>
>> I guess sort the array such that elements are sorted finally in such a
>> way that if we print them r
I think this wont work for cases with negetive nos
Ex
-2,8,-6
On Tue, Jan 10, 2012 at 6:51 AM, sravanreddy001 wrote:
>
> solution at this link:
> http://ideone.com/ifVIv
>
> for every position, (iteration)
> maitain left, right for the sums,
> keep adding elements towards the begenning to left,
Can you give an example
Say matrix is
1 1 0 0
1 1 0 0
0 0 1 1
Has it got 3 islands i.e 1-1 be in same row or they can be column wise also
i.e. 5
On Tue, Jan 10, 2012 at 7:09 AM, Ashish Goel wrote:
> there is a matrix of 1 and 0
> 1 is a island and 0 is water
> 1-1 together makes one island
@Priyanka ...Do the elements of the subarray need to be continuous ..The
example considers it continuous but still just for clarity ?
On Tue, Jan 10, 2012 at 12:50 AM, surender sanke wrote:
> using extra space of O(n) we can do it in O(n^2)
> take an array for storing cumulative sums from index i
sorry it shud be
sum of squares and xor and sumof elements
I think this shud work
Regards
Ankur
On Wed, Jan 4, 2012 at 9:52 PM, atul anand wrote:
> @ Karthikeyan :
>
> sum of cubes fails:-
>
> arr1={2,3,0,-3} = 4
> arr2={1,1,1,1} = 4
>
> On Wed, Jan 4, 2012 at
What if we check these 2 conditions
XOR and sum of elements and sizeof array same
I cudnt find any counter example
Regards
Ankur
On Wed, Jan 4, 2012 at 6:53 PM, Karthikeyan V.B wrote:
> Hi,
>
> Consider, arr1={1,2,3} and arr2={-1,-2,-3}
>
> using sum of squares method sum
x.back()]-a[i])>k))
index.pop_back();
}
For the second part that you said , yes potentially if we use queue.size()
we can miss out on continuous part ..
Thanks for pointing these out
Regards
Ankur
On Tue, Jan 3, 2012 at 4:06 AM, Ankur Garg wrote:
> @Lucifer
>
> I checked with my code
>
&g
would be great .. I am sharing the source
codes .cpp file
If u find any case thats missing ..please tell me and I will also update in
case some case misses out
Thanks very much for looking into it :)
Thanks and Regards
Ankur
On Tue, Jan 3, 2012 at 3:26 AM, Lucifer wrote:
> @Ankur..
>
> A
I think this can be solved in NlogN using binary search
Here is the idea
We take a deque which stores the index of the array in increasing order
i.e. the index with minimum value is always on the front of the deque
Now when a new element comes we check with the front of this deque .
If the dif
Dude please ask these question on Interviewstreet group..
Your queries will be answered there
Kindly adhere to the protocols of this group..
This may be one off thing but it can lead to start of interview queries.So
please understand :)
On Thu, Dec 29, 2011 at 12:35 AM, Jyoti Malik wrote:
ite 4,4 to array.
> >
> > for node 2
> > frequency = 3
> > number =2
> >
> > write 2,2,2 to the given array...
> >
> >
> >
> > On Sat, Dec 24, 2011 at 10:57 PM, Ankur Garg
> wrote:
> > > how can one do frequency sort
@Atul..your solution is correct and would do the job but its complexity wud
be nlogn .
Any better way of solving it ?
Regards
Ankur
On Sun, Dec 25, 2011 at 2:10 AM, sravanreddy001 wrote:
> any better approach than O(N log N) time?
>
> maintain a heap of nodes
> for each element
how can one do frequency sort .
Suppose we have an integer array like
1,2,3,1,2,3,1,1,2,3,4,4,3,5,3
Then 1 is appearing 4 times
2 - 3
3- 5
4-2
5-1
Then if we sort by frequency we shud have this as result
5,4,4,2,2,2,1,1,1,1,3,3,3,3,3
How to do it
--
Y
The thing is ..will it ascertain that the probability is equal
I am not sure how ur method guarantees that...
May be if you and Dave can explain the algo a bit better that wud be great .
regards
Ankur
On Sat, Dec 24, 2011 at 5:48 AM, Piyush Kansal wrote:
> Hey Ankur,
>
> What is the
Suggest an algo with which u can find a random node in an infinitely long
linked list
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email
think we can reverse the n-ary tree ,but again my doubt is what will be
leaf nodes then in that case , It seems it will be original root , so i was
confused . anyway , I will concentrate on reversing the tree only for now
based on ur definition.
Regards
Ankur
On Wed, Dec 21, 2011 at 1:08 PM
@Atul
Even i thought so..but then the definition of leaf node is that its a node
which doesnt have any children...then the answer is root of the original
tree so I got confused here :(
On Wed, Dec 21, 2011 at 12:20 AM, atul anand wrote:
> @ankur : for the given tree above instead of par
Hey Shashank
Unfortunately I cudnt understand the problem
What do u mean by reversing the tree here :(..
On Tue, Dec 20, 2011 at 11:23 PM, WgpShashank wrote:
> here is my code
>
>
> List list=new LinkeList();
>
> public List reverseTreeandReturnListContainingAllLeafNOdes(Node n)
> {
>in
Hi
Can anyone help me with this question
Code for Serializing and Deserializing a binary Tree
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, s
as 4 whereas in the answer
should be 3
Regards
Ankur
On Mon, Dec 19, 2011 at 1:16 AM, Ankur Garg wrote:
> a linear solution for this problem . although its more than O(n) but will
> never be O(n*2)..used DP to solve it
>
> space used -O(2n)
>
> int ZigZagLength(vector
a linear solution for this problem . although its more than O(n) but will
never be O(n*2)..used DP to solve it
space used -O(2n)
int ZigZagLength(vector a){
int n=a.size();
int DP[n][2];
DP[0][0]=1;
DP[0][1]=0;
DP[1][0]=2;
DP[1][1]=0;
int j;
for(int i=2;i0){
if((a[i]-a[j])*(a[j]-a[DP[j][1]])<0){
suggest algo to find k most frequently occuring numbers from a file of very
large size containing numbers.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from th
I saw this term "non-decreasing order"
So we need to sort the numbers first..it will take nlogn .
On Fri, Dec 16, 2011 at 1:12 AM, Ankur Garg wrote:
> on above algo , there is no need to calculate sum of array so we can do it
> in O(N) and not O(n).
>
>
> On Fri, Dec 16
on above algo , there is no need to calculate sum of array so we can do it
in O(N) and not O(n).
On Fri, Dec 16, 2011 at 12:59 AM, Ankur Garg wrote:
> Hi Topcoder.
>
> First of all you posted the wrong array .
>
> The array should be
>
> 4, 5, 10, 7,
]=a+c = 4 and a[N-1] =a[7]=b+c=5
a[8]-a[1]= b-a=1 and a+b=a[0]=3 gives b=2 and a =1
Now we have a=1,b=2
So we traverse from a[1] to a[N-2] to calculate values c to h
c= a[1]-a=4-1=3
d=a[2]-a=5-1=4
e=a[3]-a=6-1=5
similarly f=a[4]=6,g=a[5]=7 and h=a[6]=8
This will work in O(n)
Regards
Ankur
On Thu, D
from p.
3. Space should not exceed by k units.
4. No saving of nodes to hard discs.
5. No recursion.
Regards
Ankur
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To u
Given an array-based heap on n elements and a real number x, efficiently
determine whether the kth smallest element in the heap is greater than or
equal to x. Your algorithm should be O(k) in the worst-case, independent of
the size of the heap.
This question was also asked in Amazon
--
You rece
By Max Heapify I thought u meant to say u are making a Max Heap .. In case
you use Coreman Definition Of max Heapify it just heapifies assuming the
heap has been formed, But u need to make a max Heap first dude :)
P.S-> Clarify your concepts before posting the link :(
On Tue, Dec 13, 2011 at 12:1
Max Heapify is O(n).
On Mon, Dec 12, 2011 at 11:43 PM, ankit gupta wrote:
> apply MAXHEAPIFY on root ode and extract the root node
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@go
Agree with dave..Its still O(n)
On Mon, Dec 12, 2011 at 10:57 PM, Dave wrote:
> @Sagar: Don is correct. n/2+n/4+n/8+... ~= n. But even the first
> round, involving n/2 comparisons, is O(n).
>
> Dave
>
> On Dec 12, 11:23 am, sagar pareek wrote:
> > Yes Mr. DoN
> >
> > First round of Tournament s
> of action..
>
> On Thu, Dec 8, 2011 at 6:27 PM, Ankur Garg wrote:
>
>> Can we detect if a loop is present in Linked List if only head ptr is
>> given
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorith
Can we detect if a loop is present in Linked List if only head ptr is given
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algoge
cWas it offcampus or on campus recruitment dude.
On Sat, Dec 3, 2011 at 12:5i7 PM, atul anand wrote:
> @payal : last problem is a dutch flag problem.
>
>
> On Sat, Dec 3, 2011 at 3:33 AM, payal gupta wrote:
>
>> congrats..:):)
>> plzz...elaborate the last two problemsand it vud be very grate
ich is nothing but,
> F(12, 3) = MAX
> {
> 1/2 + F(10, 2) ,
> 2/3 + F(9, 2) ,
> 2/4 + F(8, 2) , // this will yield the
> maximum sum..
> 3/5 + F(7, 2) ,
>
:
> >
> >
> >
> >
> >
> >
> >
> > > Optimal split: [0,0][1,1][0,0][1,1][0,1][1,0]
> > > Expected value of optimal split: 0 + 1 + 0 + 1 + 1/2 + 1/2 = 3
> > > why this is not the optimal split???
> >
> > > On Sun, Nov 27,
>
> S = empty
> while i = input item existss
> if i in S output "i has a duplicate";
> insert i in S
> end
>
> XOR is generally useful only for detecting a single item that's
> included in a list an odd number of times rather than an even number
> of times.
&
You have an array with *n* elements. The elements are either 0 or 1. You
want to *split the array into kcontiguous subarrays*. The size of each
subarray can vary between ceil(n/2k) and floor(3n/2k). You can assume that
k << n. After you split the array into k subarrays. One element of each
subarray
^^+1..how matrix formed ??
But as Gene said we can use a set to store all the unique elements
Now we xor all the set elements and then xor them with the elements of the
array . This wud give us the repeating element as all the elements coming
once will be 0(xored twice) and repeating element wud b
:(
On Fri, Nov 25, 2011 at 12:57 AM, Ankur Garg wrote:
> As it seems to me this can be solved like this
>
> Find LCA(Least common ancestor) of node x and z .. See if it equals y or
> not . If not recursively search for y in left and right subtree of LCA ..If
> you find y in the
answer just that complexity would be a bit
large (greater than n) but space wll be O(1) neglecting stack space during
recursive calls
I coded the same and it works to me ..
If anyone can suggest a finer approach that wud be great :)
Regards
Ankur
On Thu, Nov 24, 2011 at 11:28 PM, Nitin Garg
t; > while (p > 0 && stk[p - 1] >= in) p--; // pop
> > a[i] = (p > 0) ? stk[p - 1] : 0;
> > stk[p++] = in; // push
> > }
> >
> > }
> >
> > On Nov 23, 5:13 am, Ankur Garg wrote:
> >
> >
> >
> > > Solutio
p.second]=0;
}
}
On Wed, Nov 23, 2011 at 3:43 PM, Ankur Garg wrote:
> Solution given by tech coder is fine and is working .. I coded it and its
> working perfectly using stack
>
>
>
> On Wed, Nov 23, 2011 at 2:50 PM, Gene wrote:
>
>> It's a nice problem, and this
Solution given by tech coder is fine and is working .. I coded it and its
working perfectly using stack
On Wed, Nov 23, 2011 at 2:50 PM, Gene wrote:
> It's a nice problem, and this solution is almost right.
>
> Process the input in _reverse_ order, which means we'll also generate
> output in r
I think Merge Sort doesnt require any swapping . So , for 3 my answer wud
be Merge Sort
On Mon, Nov 21, 2011 at 11:55 AM, Dave wrote:
> @Kumar: For question 1, the answer is radix sort. It doesn't use data
> comparisons at all.
>
> Dave
>
> On Nov 21, 12:04 am, kumar raja wrote:
> > if we have
a linked list contains
2 19 _ _ 3 47 _ _ _ 2 20 _ _ ..and so on
I have to fill those empty nodes with numbers whose sum is equal to the
numbers
occurring just before the gaps and the number of gaps is determined by the
node
which is at 2 distance before the gaps with the limitation that
Can u provide a pseudo code for the same and c if it works
On Thu, Nov 17, 2011 at 2:37 AM, sravanreddy001 wrote:
> Start with counting sort of the input.
> Use shuffling algorithm on it.
>
> Store index as cumulative sums of counts.
>
> --
> You received this message because you are subscribed
Given a string of lowercase characters, reorder them such that the same
characters are at least distance d from each other.
Input: { a, b, b }, distance = 2
Output: { b, a, b }
How to approach this question ?
--
You received this message because you are subscribed to the Google Groups
"Algorit
Radix Sort
On Mon, Nov 14, 2011 at 1:57 PM, Vijay Khandar wrote:
> Which is the sorting algm sorts the integers [1...n^3] in
> O(n).
> a)Heapsort
> b)Quicksort
> c)Mergesort
> d)Radix sort
>
> please tell anyone.
> Vijay.
>
> --
> You received this message becaus
We can use a trie here .. Create a trie with all words of dictionary .
Now delete the last character of the word and check if such a word is a
valid word . If not see if adding a new character can make it a valid word
. If not delete the next character and repeat the process again .
This is what
How to find highest power of 2 in an integer
Suppose number is
1 - Highest power of 2 is 1
00011 - Highest power of 2 is 2
11000 - Highest power of 2 is 5
No loops
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group,
@Srinivas
Wat if the string is abc
then it reduces to cc :) ...So size 2 can also be there.so u cant say it
will be 1 "always"
On Sun, Nov 13, 2011 at 12:01 AM, Srinivasa Chaitanya T <
tschaitanya@gmail.com> wrote:
>
>
> On Sat, Nov 12, 2011 at 4:24 PM, Snoopy Me wrote:
>
>> Given a string
Well it aint O(n) ..:P ...The erase part will be complex and will take
shifting string parts . So complexity will be O(n^2) for str.erase operation
On Sat, Nov 12, 2011 at 8:34 PM, Ankur Garg wrote:
> The Complexity of my solution is of Order n . At most I Traverse the whole
> string
The Complexity of my solution is of Order n . At most I Traverse the whole
string twice ..
On Sat, Nov 12, 2011 at 8:29 PM, vikas wrote:
> seems like quesion of permutation, it will take all the permutation to
> check which one can lead to answer, there will be always be more than
> one solutio
Hey I coded it . The answer is either 2 or 1 ..So I guess you guys are rite
:)
Here is the code
void smallestString(string &str){
if(str.empty()) return;
int j=0,i,k=0;
for(i=1;i0)j--;
i=j;
}
}
}
On Sat, Nov 12, 2011 at 8:19 PM, Nitin Garg wrote:
> If yes, how d
Did they ask you to code this or just asked logic
On Sat, Nov 12, 2011 at 4:57 PM, surender sanke wrote:
> @myself
>
> if number of distinct characters are equal then its final string size is 2.
> else there are more repeated characters other than distinct characters
> then its 1
>
> correct m
think this way we just make at most
2 pass (in case the petrol pump of choice is just before the first point )
.
Please comment in case you think its right/wrong
Regards
Ankur
On Mon, Oct 24, 2011 at 10:15 PM, ravindra patel
wrote:
> @Nitin, excellent algo.
>
> >> if S < 0 &
change
low=high and high = 2*high and again apply Binary Search. In the code
before applying binary search u each time check whether k wrote:
> @Ankur Don't think there's any major reason for using powers of 2 except
> the fact that computing the powers of 2 can be done very
Use Binary Search
start = 2^n-1 high =2^n where n=0,1
On Mon, Oct 24, 2011 at 12:28 AM, sunny agrawal wrote:
> hint 1: try to find 2 indexes i, j such that a[i] <= K <= a[j]
>
>
> On Sun, Oct 23, 2011 at 11:23 PM, Ankuj Gupta wrote:
>
>> Given a sorted array of Infinite size, find an elemen
if you are dealing with some very large arrays.
>
> Dan :-)
>
>
> On Oct 14, 9:44 pm, Ankur Garg wrote:
> > @Dan ..can you post the algo here or link to the book??
> > @Anika ...yes please post the code here..but please explain a bit about
> > underlying algo .
{You are given an unsorted array of integers. You have to find out the first
sub array whose elements when added sum up to zero.
eg:- int Array[] = {1,2,-4,-3, 6 ,-3.}Here sub array is -3,6,-3 bcos
adding all these sum to zero. A sub array can be of size 2 to whole length
of the array. You can
@Shashank ..+1 ..I wud say he must be given a tuning award :D :D for
solving such eternal conundrum ;)
On Mon, Oct 17, 2011 at 2:37 PM, WgpShashank wrote:
> @wladimir , its PPT (Pythagoras triplets ) but its number theory based
> approach http://en.wikipedia.org/wiki/Pythagorean_triple might
*Turing :P
On Mon, Oct 17, 2011 at 3:51 PM, Ankur Garg wrote:
> @Shashank ..+1 ..I wud say he must be given a tuning award :D :D for
> solving such eternal conundrum ;)
>
>
>
> On Mon, Oct 17, 2011 at 2:37 PM, WgpShashank
> wrote:
>
>> @wladimir , its PPT (Pythag
t,level+1,minL,maxR,left,right);
if(level<0)
left[abs(level)] +=root->data;
else
right[level] +=root->data;
}
On Sun, Oct 16, 2011 at 4:23 PM, Ankur Garg wrote:
> I am assuming we are allowed to use space ..With that i make 2 arrays 1 to
> store values from left side and oth
I am assuming we are allowed to use space ..With that i make 2 arrays 1 to
store values from left side and other from right side .
Here is the func
void getLevelSum(node* root,int &minL,int &maxR,int level){
if(!root) return ;
minL = min(minL,level);
maxR = max(maxR,level);
getLevelSum(root-
@Sunny ..Superb Algo ..but can you share some link where we can read abt it
:)..especially where the info abt the equation u used is given
Thanks in Advance
On Sat, Oct 15, 2011 at 12:37 PM, Kunal Patil wrote:
> @Sunny: Thanks for the info !! That's gr8..& your logic also seems to be
> workin
@Dan ..can you post the algo here or link to the book??
@Anika ...yes please post the code here..but please explain a bit about
underlying algo ...(algo is more important than actual code )
On Sat, Oct 15, 2011 at 1:54 AM, Dan wrote:
> On Oct 13, 7:52 pm, "shiva@Algo" wrote:
> > Convert an ar
not sure how it will work in O(n) time then.
>>
>> Thanks,
>> - Ravindra
>>
>>
>> On Fri, Oct 14, 2011 at 12:25 AM, Ankur Garg wrote:
>>
>>> @rahul...How do u choose z and x for computing z^2 -x^2 ?
>>>
>>> On Thu, Oct 13, 2011 at
@rahul...How do u choose z and x for computing z^2 -x^2 ?
On Thu, Oct 13, 2011 at 11:34 PM, rahul wrote:
> You can create a hash with sqrt(z2-x2). This will make it o(n). The
> interviewer just made it lil tricky. That's all
>
> --
> You received this message because you are subscribed to the Go
BTW can we solve this by hashing..That is the only feasible solution which
comes to my mind to reduce the time complexity ?
On Thu, Oct 13, 2011 at 11:20 PM, Ankur Garg wrote:
> Dude this is nothing but 3 sum problem
>
> http://en.wikipedia.org/wiki/3SUM
>
> Ask interviewer to
Dude this is nothing but 3 sum problem
http://en.wikipedia.org/wiki/3SUM
Ask interviewer to check this link and say he has gone mad!! :P
Regards
Ankur
On Thu, Oct 13, 2011 at 10:29 PM, ravindra patel
wrote:
> Hi,
> Another question I faced in Amazon F2F.
>
> Given an unsor
oo much space..
> Balanced Binary tree can be Better ...??
>
>
> On Tue, Oct 11, 2011 at 12:16 AM, Ankur Garg wrote:
>
>> I think this can be done through tries
>>
>> Any better solution ?
>>
>> On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal wrote:
>>
I think this can be done through tries
Any better solution ?
On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal wrote:
> remove duplicate words from a string with min. complexityy.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To
Memoization ?
On Mon, Oct 10, 2011 at 6:34 PM, arvind kumar wrote:
> Can anyone tell me how to go about with the memorization technique to
> retrieve values from already stored values,in case of eveluating
> sequences(fibonacci series,etc).?
>
> --
> You received this message because you are sub
@Sravan ..Counting Sort takes O(n) time but it needs range of nos to be
known
@Snehi jain..there is no range given so am not sure if count sort will work
,Can you please elaborate a bit on ur method
Ankur
On Mon, Oct 10, 2011 at 10:09 PM, sravanreddy001
wrote:
> Just went throught what a co
Given a 2D matrix which is both row wise and column wise sorted. Propose an
algorithm for finding the kth smallest element in it in least time
complexity
A General Max Heap can be used with k space and n+klogk complexity
Any other solution or even a way by which we dont scan the whole matrix to
Given an unsorted array of Integers
Find 2 nos whose diff is minimum
Say Array is 4 2 18 19 11 8 5
Nos are 18 and 19
Algo shud be of O(n)
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@goog
Is it sum of bits or sum of digits ?
On Sun, Oct 9, 2011 at 1:39 PM, wujin chen wrote:
> Given a positive number N, find a minimum number M greater than N, M has
> the same length with N and the sum of the bits are equal.
>
> example:
> N=134 , M=143, // 1+3+4=1+4+3
> N=020, M = 101, //2=1+1
>
Can anyone suggest a pseudocode handling rotations in an AVL tree for
deleting a node
I couldnt find one in the internet and was unable to derive a proper logic
which cud be transformed into code :(
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" g
+1
On Sun, Oct 9, 2011 at 2:07 AM, Sunny wrote:
> Now All of the messages are being Moderated and will be posted on the
> group only if they are found relevant, any irrelevant post be simply
> discarded without any notification till percentage of irrelevant posts
> reduces by a significant amoun
Hi ,
Can anyone think of any better for doing this other than converting into
List and then converting back again to BST ..
Regards
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.
mpty()) {
s. push(val);
return;
}
temp = s.pop();
ReverseHelper(s,val);
s.push(temp);
}
Remember to pass stack as reference
Regards
Ankur
}
On Fri, Oct 7, 2011 at 7:54 PM, sravanreddy001 wrote:
> in place means:
>
> use constant extra space
Implement recursive merge sort for first question
For second just swap the values of node and node b
On Wed, Oct 5, 2011 at 9:18 PM, 9ight coder <9ightco...@gmail.com> wrote:
> 1.perform inplace(we cant create new node)merge sort of two sorted
> linked list.(asked in amazon 1 mon before)
> 2.a
Find out the smallest segment in a document containing all the given words.
Desired Complexity is O nlogK ..n is the total no of words in the document
and k is the number of input words
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post
Code for Compression
I am doing it inplace
void convert(char* s,int len){
int i=0;
int count=1;
int index=1; //*maintain the index where number is to be added*
for(i=1;i<=len;i++){
if(s[i]==s[i-1])
count++;
else{
s[index-1]=s[i-1];*//put the cha
Keep an array to store multiplication of numbers like for input
9 3
U have to compute 9^9
So an array to store the digits and do simple multiplication like 9*9 will
give 81 so Array will have 81
then 81*9 729 ..so on
Then output the first k digits and last k digits of the array
Any1 having
Many times this problem has been discussed ..Please check the archives yaar
:(
On Mon, Oct 3, 2011 at 11:39 PM, Shruti Gupta wrote:
> I had inserted 0 instead of 1 The corrected code will be:
> public static void setZeros(int[][] matrix) {
>int[] row = new int[matrix.length];
>int[] col
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
ht
Committed to launch a website,formatting ..clarifying in case you mistook it
for somethin else :D
On Mon, Oct 3, 2011 at 7:50 PM, Ankur Garg wrote:
> Nice Idea but for pulling this you need committed people :)
>
> On Mon, Oct 3, 2011 at 7:36 PM, sukran dhawan wrote:
>
>> Hell
1 - 100 of 515 matches
Mail list logo