Re: [algogeeks] Find all the subarrays in a given array with sum=k

2016-03-23 Thread Saurabh Agrawal
Hi, This question was asked in Amazon interview few days back. Please explain to me the part after building the SUM array. With Regards, Saurabh Agrawal On Sun, Feb 21, 2016 at 9:08 PM, Saurabh Paliwal < saurabh.paliwa...@gmail.com> wrote: > Hi, > I can think of an approach tha

Re: [algogeeks] Openings in Mentor Graphics,Noida Location

2016-02-18 Thread Saurabh Agrawal
Hi, PFA. With Regards, Saurabh Agrawal On Tue, Nov 17, 2015 at 10:04 AM, Ashish kumar Jain <akjlucky4...@gmail.com> wrote: > Anybody interested to join Mentor Graphics Noida having 1-10 years of > experience in C/C++/DS/Algo can forward his/her resume to me. > >

Re: [algogeeks] Facebook question!

2012-10-01 Thread saurabh agrawal
Do we need to handle cases when the same string will appear again?? In that case we can sort individual array and remove duplicates. On Mon, Oct 1, 2012 at 9:54 AM, Rahul Singh riit1...@gmail.com wrote: check this out.. #includeiostream #includestdlib.h using namespace std; void

Re: [algogeeks] amazon

2012-05-27 Thread saurabh agrawal
@atul: if i have understood .. ur solution will break when the string has repeated characters. e.g. for baa On Tue, May 22, 2012 at 3:43 PM, partha sarathi Mohanty partha.mohanty2...@gmail.com wrote: sorry it was treeset Here is the code.. public class asd1 { public static

Re: [algogeeks] amazon

2012-05-27 Thread saurabh agrawal
. On Mon, May 28, 2012 at 12:16 AM, saurabh agrawal saurabh...@gmail.comwrote: @atul: if i have understood .. ur solution will break when the string has repeated characters. e.g. for baa On Tue, May 22, 2012 at 3:43 PM, partha sarathi Mohanty partha.mohanty2...@gmail.com wrote: sorry

Re: [algogeeks] Cpp problem

2012-05-27 Thread saurabh agrawal
const allows this function to be called on constant object. So if someone creates an const obj of this class. Assignments can be done. On Mon, May 28, 2012 at 12:23 AM, amrit harry dabbcomput...@gmail.comwrote: complex_number const operator =(complex_number temp) const { return

Re: [algogeeks] Re: Algo for Search in a 2D Matrix

2012-05-27 Thread saurabh agrawal
Yes, navin thats a good solution... ... we dont need to work on the whole array but of size k x k (k rows and k columsn only). Rest of the array we can simply ignore.. complexity of youngify is O(k) for every removing every element. we have to remove k-1 elements so complexity of whole

Re: [algogeeks] BST

2011-09-21 Thread saurabh agrawal
Do a BFS of the tree, keep a separator to masrk where a level ends.. create the linklist for every level. On Wed, Sep 21, 2011 at 6:00 PM, prasanth n nprasnt...@gmail.com wrote: Given a binary search tree, design an algorithm which creates a linked list of all the nodes at each depth (i.e., if

[algogeeks] Amazon SDE onsite interview question

2011-09-20 Thread saurabh agrawal
Given an n-ary tree of resources arranged hierarchically. A process needs to lock a resource node in order to use it. But a node cannot be locked if any of its descendant or ancestor is locked. You are supposed to: - write the structure of node - write codes for Islock()- returns true if a given

[algogeeks] Amazon question SDE

2011-09-20 Thread saurabh agrawal
Design an algorithm to perform operation on an array Add(i,y)- add value y to i position sum(i) - sum of first i numbers we can use additional array O(n) and worst case performance should be O(log n) for both operation -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Amazon question SDE

2011-09-20 Thread saurabh agrawal
be possible in O(1)... If i am wrong and it can be possible in O(log n) then plz tell On Tue, Sep 20, 2011 at 3:28 PM, saurabh agrawal saurabh...@gmail.comwrote: Design an algorithm to perform operation on an array Add(i,y)- add value y to i position sum(i) - sum of first i numbers

[algogeeks] What is the time to get min element from the binary max heap !!

2011-09-20 Thread saurabh agrawal
What is the time to get min element from the binary max heap !! You might be given the heap as API. I mean, you dont have implementation of the heap. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: What is the time to get min element from the binary max heap !!

2011-09-20 Thread saurabh agrawal
I think, we have to delete all the elements from the heap which takes o(n*logn). Please share if you have any better solutions. On Tue, Sep 20, 2011 at 6:38 PM, saurabh agrawal saurabh...@gmail.comwrote: What is the time to get min element from the binary max heap !! You might be given

Re: [algogeeks] Re: What is the time to get min element from the binary max heap !!

2011-09-20 Thread saurabh agrawal
: We can find minimum element in O(n) time. Just compare leaf nodes in max heap tree. Cheers Janardhan Reddy Cheruvu +91-9642421117 On Tue, Sep 20, 2011 at 6:39 PM, saurabh agrawal saurabh...@gmail.comwrote: I think, we have to delete all the elements from the heap which takes

Re: [algogeeks] URGENT suggestion REGARDING placement...............

2011-09-18 Thread saurabh agrawal
Vivek, if there are more god companies going to visit ur college, then u can wait for them. Everything depends on your interest, but if you want to go for pure coding companies, then u should skip delloite. Amazon is also coming for intern, u can wait for that.. Thanks Saurabh Agrawal BE CSE

[algogeeks] Building a max heap takes O(n) time irrespective of the array being sorted / unsorted.

2011-09-15 Thread saurabh agrawal
Building a max heap takes O(n) time irrespective of the array being sorted / unsorted. Can someone prove that. I already know that Heap can be constucted in o(n*log(n)) time. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] C Trick

2011-09-13 Thread saurabh agrawal
Priyanka.. ideally u should not use any function calls to solve this question.. because they internally might use conditional operators or if else.. OR u can give your own definition of abs() function With Regards Saurabh On Wed, Aug 24, 2011 at 11:06 PM, priyanka raju priyark...@gmail.comwrote:

Re: [algogeeks] Re: Finding connection b/w 2 profiles

2011-09-13 Thread saurabh agrawal
@DON: DFS should not be applied because, there can exist multiple paths from A to C, but the question is to find the shortest path. So, u might end up getting longer path. Otherwise you have to search for all possible paths which will be very inefficient. Saurabh Agrawal On Tue, Sep 13

Re: [algogeeks] Best Logic for List Flatting ( Double linked list )

2011-09-11 Thread saurabh agrawal
what do you mean by flatting?? Are all these questions asked in facebook.. would you like to share the links ?? On Sun, Sep 11, 2011 at 3:24 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A,

Re: [algogeeks] semaphores

2011-09-11 Thread saurabh agrawal
does not have any list(of waiting processes) associated with it and just is a kind of lock and key model with no waiting THERE IS ONE THREAD WITH SUBJECT : MUTEX You cna search that for more clarity.. Thanks and Regards Saurabh Agrawal On Sat, Sep 10, 2011 at 10:52 AM, ravi maggon maggonr

Re: [algogeeks] c

2011-08-24 Thread saurabh agrawal
Does anyone has idea about what pacific asked for.? On Sun, Aug 21, 2011 at 11:01 AM, pacific :-) pacific4...@gmail.com wrote: Is const a compiler level construct ? #include stdio.h int main() { const int i = 0; int * p ; p = (int *) i; *p = 2; printf((i,p): %x %x \n,i,p);

Re: [algogeeks] Adobe Interview - 20/08/2011

2011-08-22 Thread saurabh agrawal
How did u solved : 3) There is a list containing the checkin and checkout time of every person in a party . The checkin time is in ascending order while the checkout is random . Eg: Check_inCheck_out Person 1 8.00 9.00

[algogeeks] Compute a+bx2+cx3+dx4+... efficiently (a,b,c...given)

2011-08-22 Thread saurabh agrawal
Compute a+bx2+cx3+dx4+... efficiently (a,b,c...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

[algogeeks] Given an array, find out whether there exists a triplet which can form sides of triangle.

2011-08-22 Thread saurabh agrawal
Given an array, find out whether there exists a triplet which can form sides of triangle. You are not allowed to modify the array. PLease dont give o(n^3) solution there exists a solution with nlog(n) i think -- You received this message because you are subscribed to the Google Groups

[algogeeks] Reverse of dutch national flag

2011-08-15 Thread saurabh agrawal
In a given array of elements like [a1, a2, a3, a4, . an, b1, b2, b3, b4, ... bn, c1, c2, c3, c4, cn] without taking a extra memory how to merge like [a1, b1, c1, a2, b2, c2, a3, b3, c3, an, bn, cn] ..??? Time complexity should be o(n). you can not use stack or any

Re: [algogeeks] Re: strings

2011-05-26 Thread saurabh agrawal
Gys, this problem can b esolved using dynamic programming in o n^2.l recursive/iterative approach wont work. Regards Saurabh On Thu, May 26, 2011 at 4:41 PM, sunny agrawal sunny816.i...@gmail.comwrote: @senthil nopes, it will not work eg. S3 = cba S1 = a S2 = bc count matches but not

[algogeeks] how to convert a floating point number into binary representation.

2011-05-24 Thread saurabh agrawal
-- 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

[algogeeks] convert a number from one base to another.

2011-05-21 Thread saurabh agrawal
Hi, can someone give an algorithm to directly convert a number in a given base to a number in another base, without converting it into some another intermediate base. I have done that using some numerical analysis techniues, but dont remember now. Thanks in advance. -- You received this

Re: [algogeeks] Re: Google Q

2011-05-20 Thread saurabh agrawal
On May 18, 8:29 am, saurabh agrawal saurabh...@gmail.com wrote: Dave, u said: a max-heap of the smallest half of the elements but if the number are randomply generated, then how will you get to know whether a number belongs to smallest half OR lager half.. i didnt got

Re: [algogeeks] Re: Google Q

2011-05-18 Thread saurabh agrawal
Dave, u said: a max-heap of the smallest half of the elements but if the number are randomply generated, then how will you get to know whether a number belongs to smallest half OR lager half.. i didnt got it... On Sat, May 14, 2011 at 9:10 PM, Dave dave_and_da...@juno.com wrote: @Ashish:

Re: [algogeeks] Google ques

2011-04-10 Thread saurabh agrawal
http://tech-queries.blogspot.com/ On Fri, Apr 8, 2011 at 7:22 PM, saurabh agrawal saurabh...@gmail.comwrote: ou are given an array A of k values which contain int values in sorted (asec) order. Find top k values (asec) which can either be the number from the array A, or sum of any two

[algogeeks] Google ques

2011-04-08 Thread saurabh agrawal
ou are given an array A of k values which contain int values in sorted (asec) order. Find top k values (asec) which can either be the number from the array A, or sum of any two numbers from A or sum of any three numbers from A. So, if A's values are represented as : a1,a2,...,ak , the possible

[algogeeks] random number generator

2011-03-17 Thread saurabh agrawal
Given a function which returns true 60% time and false 40% time. Using this function you have to write a function which returns true 50% of the time. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Given an integer n , you have to print all the ways in which n can be represented as sum of positive integers

2011-03-11 Thread saurabh agrawal
Given an integer n , you have to print all the ways in which n can be represented as sum of positive integers -- 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

Re: [algogeeks] Re: Given an integer n , you have to print all the ways in which n can be represented as sum of positive integers

2011-03-11 Thread saurabh agrawal
. This choice will affect the way you write the recursive function. Dave On Mar 11, 9:33 am, saurabh agrawal saurabh...@gmail.com wrote: Given an integer n , you have to print all the ways in which n can be represented as sum of positive integers -- You received this message because you

Re: [algogeeks] Re: Construct Binary Tree From Ancestor Matrix

2011-03-08 Thread saurabh agrawal
1 2 3 4 1 0 1 1 0 2 0 0 1 0 3 0 0 0 0 4 0 1 1 0 Node numbers used in matrix are in bracket 5(3) | | 10(2) / \ / \ 12(1) 13(4) For every row in the matrix, calculate the number of non - zero numbers. This will give the level of that node in the tree. Now the node with level 0 is root. Traverse

Re: [algogeeks] Re: An interesting question

2011-03-08 Thread saurabh agrawal
@rajnish: i think u missed the point , the matrix is binary.. so how will you store -1 in it. @pacific: Will you solution work fine if 0 th row has all 1's and 0th column has atleast one zero.?? On Mon, Mar 7, 2011 at 1:09 AM, yogesh kumar yoku2...@gmail.com wrote: @pacific: Good Algorithm

Re: [algogeeks] Pairwise Sum Array

2011-02-24 Thread saurabh agrawal
Last three values could be: 1.b+e 2.c+e 3.d+e On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: I think.. As like no are a,b,c,d,e so sum will be a+b,a+c,a+d,a+e,b+c,b+d,b+e,c+d,c+e,d+e; so maximuum value will be d+e which is last element of array given

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread saurabh agrawal
Simple one line solution without looping and efficient : i=(i7)?(i|7)+1:i) On Sun, Sep 26, 2010 at 8:43 AM, coolfrog$ dixit.coolfrog.div...@gmail.comwrote: @Dave very nice one line solution.. we all are revolving around x3 concept... On Sat, Sep 25, 2010 at 10:17 PM, Dave

Re: [algogeeks] Number problem

2010-09-21 Thread saurabh agrawal
int function(int n){ int a[10]={0}; int result =0; while(n){ if(a[n%10]==0){ a[n%10]=1; result=10*result+n%10; } n/=10; } return result;` } On Wed, Sep 22, 2010 at 12:39 AM, Albert alberttheb...@gmail.com wrote: Given a number find the number by eliminating the

Re: [algogeeks] Re: Number problem

2010-09-21 Thread saurabh agrawal
; } Dave On Sep 21, 3:12 pm, saurabh agrawal saurabh...@gmail.com wrote: int function(int n){ int a[10]={0}; int result =0; while(n){ if(a[n%10]==0){ a[n%10]=1; result=10*result+n%10; } n/=10;} return result;` } On Wed, Sep 22, 2010

Re: [algogeeks] Re: Explain

2010-09-10 Thread saurabh agrawal
Thanks a lot umesh...but still i am in confusion that: after first processing : A is replaced by B after second proecessing B is replaced by A then why again this A is not being replaced by #define A macro.. why it is not going in an infinite loop...because i think there is no fiexed order of

[algogeeks] Explain

2010-09-09 Thread saurabh agrawal
Can somebody explain how the macros are expanded regarding order in which they are used...etc... also explain this example : #define A B #define B A what is the effect of this and whether it will go in an infinite recursive call or not and why? -- You received this message because you are

Re: [algogeeks] Explain

2010-09-09 Thread saurabh agrawal
@umesh kewat #includestdio.h int main(){ int A =4; #define A B #define B A printf(%d,A); return 0; } This code works fine...but as you have explained the later A used in printf statement must have replaced by B. In that case there must be a compiler error The identifier not defined. But this