to get the non repeating element we have to travese array atleast once.so
Time complixity has to minimum o(n).as I suppose..
The XOr solution will fail because odd number will be there...
Hashing itself require o(n) space in worst case.
On Mon, Apr 18, 2011 at 12:40 AM, sravanreddy001
@dave..Can you please explain your logic ..
Regards,
Ashish
On Thu, Feb 24, 2011 at 6:32 AM, Dave dave_and_da...@juno.com wrote:
Try this:
int i,k,n;
long long j,nsq;
for( n = 31623 ; n 10 ; ++n )
{
nsq = (long long)n * (long long)n;
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
take last three value
1.c+d
2.c+e
3.d+e
eq(1)-eq(2)=d-e;
solving it with 3rd eq will give d and e
and with these value we can get other
There must be another good solution..please let me know .
Thanks
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
The basic solution which is coming to the mind is to covert string first
palindrome and apply livishthein distance to both string(original one and
changed string) to check how many substiutions you require for the
palindrome.
On Wed, Feb 23, 2011 at 9:11 PM, radha krishnan
take an array of 10 ,travese the whole rcord and apply min heap on these 10
elements.
as like first 10 no will be there and we apply minheap so we will get
minimun num in these 10 number..If next numbe is greater then minimun no in
array ..we will replace it and apply minheap ...
On Thu, Feb 17,
trie tree will be better to implement
On Thu, Feb 17, 2011 at 11:07 AM, Jammy xujiayiy...@gmail.com wrote:
Greedy, always choose the remaining one that is the lexicographically
smallest since choose any other way will yield a lexicographically
greater one.
void concante(char **strings, int
jalaj back to algogeeks..
On Mon, Feb 7, 2011 at 6:09 PM, rahul rai raikra...@gmail.com wrote:
Are all the integers positive only ?
On 2/7/11, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
you are given a bst where each node has a int value , parent pointer ,
and
left and right pointers
didn't get your question dude
On Wed, Jan 12, 2011 at 10:39 PM, Pratik Bhadkoliya
pkbhadkol...@gmail.comwrote:
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) is an ordered
list of positive integers
Let magic(value) denote the number of such ordered lists that exist
such that
use a array of 10 and apply min heap
On Thu, Oct 21, 2010 at 7:05 PM, Vinay... vinumars...@gmail.com wrote:
how do u find 10 most repeating words on a large file containing words
in most efficient way...if it can also be done using heapsort plz post
ur answers..
--
You received this
take two pointer p and q
p=a[0] and q=a[n-1];
sum=p+q;
if(sumx)
q--;
if (sumx)
p++;
On Sun, Oct 10, 2010 at 6:54 PM, Rohit email.rohit.n...@gmail.com wrote:
On Oct 10, 10:48 am, Shravan shravann1...@gmail.com wrote:
http://ideone.com/D5W2y
Good :).
What if array is unsorted. What
This question was asked in google interview
one solution for this question is DP
make a matrix p (all rows and columns are initialized to zero)
if(a[i][j]==1]{
p[i][j]=min(p[i-1][j],p[i,j-1],p[i-1][j-1]]+1;
}
else p[i][j]=0;
f
find p[i][j] such that its has max value.
On Sun, Oct 10, 2010 at
ohh..I think my solution will work on square not on rectangles.
On Sun, Oct 10, 2010 at 8:13 PM, Mridul Malpani malpanimri...@gmail.comwrote:
@ ashish agarwal
ur solution will not work on this :
10101
0
1
11000
On Oct 10, 6:59 pm, ashish agarwal ashish.cooldude...@gmail.com
the principles of
Kadane's algo :
http://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm
On Mon, Sep 6, 2010 at 3:50 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
int max=0,sum=0,begin=0,end=0,i=0;
for(int j=0 to n){
sum+=a[j];
if(maxsum){
max=sum;
begin=i
Can anybody tell me least increasing sub sequence in nlogn
please try to provide code in C
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send
can you give link for this
On Sat, Sep 11, 2010 at 6:10 AM, Nikhil Agarwal
nikhil.bhoja...@gmail.comwrote:
This has been discussed already.Please refer that post I have provided the
actual code .
On Sat, Sep 11, 2010 at 3:20 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
Can
aham aham
On Fri, Sep 10, 2010 at 12:56 PM, Shashank Krishna sasan...@gmail.comwrote:
Excellent Compilation of Interview Questions
Visit
http://www.cracktheinterview.org/
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm
On Mon, Sep 6, 2010 at 3:50 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
int max=0,sum=0,begin=0,end=0,i=0;
for(int j=0 to n){
sum+=a[j];
if(maxsum){
max=sum;
begin=i;
end=j;
}
else if(sum0){
i=j+i;
sum=0
int max=0,sum=0,begin=0,end=0,i=0;
for(int j=0 to n){
sum+=a[j];
if(maxsum){
max=sum;
begin=i;
end=j;
}
else if(sum0){
i=j+i;
sum=0;
}
return sum;
i will tell the starting index and j will tell ending index;
o(n);
correct me if i am wrong
On Mon, Sep 6, 2010 at 1:42 PM, bittu
I think 4.
On Sat, Sep 4, 2010 at 9:03 AM, Maria lydwin.ma...@gmail.com wrote:
How many processes are created in this snippet?
Main()
{
Fork();
Fork() fork () || fork ();
Fork ();
}
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
In this method overflow will be there..if number is just bigger...so by
doing XOR we can get missing number and repeated number .
take xor of all element of array and take this xor with array[1...n]
So we get xor of two numbers.
now get set bit of this xor and proceed.
On Thu, Sep 2, 2010 at
I think it will be 1x
On Wed, Sep 1, 2010 at 10:53 PM, Yan Wang wangyanadam1...@gmail.com wrote:
Maybe you misunderstand the question.
The question is how to compute 2^X where 0 = X = 9?
How?
On Wed, Sep 1, 2010 at 10:48 PM, Ruturaj rutura...@gmail.com wrote:
a 5 digit number is
but addition also should be in array
On Sun, Aug 22, 2010 at 3:05 AM, arpit agarwal erarpitagar...@gmail.comwrote:
Just find out the max and 2nd max in n + log(n) -2 steps and add them.
there is no need for sorting as such
--
You received this message because you are subscribed to the
take the sum of array and product.
if they were present then sum will be n(n-1)/2 and product will be n!.
make two eq of a+b and a-b with these values and get the num
On Thu, Aug 12, 2010 at 5:26 AM, vijay auvija...@gmail.com wrote:
How to find two missing numbers from an unsorted continuous
a[1n] b[1...m]
find median of two array say n1 and m1..if n1m1 then median of both array
can't be in in region a[n1..n] and b[1...m1]so now search space is
reduced ..and we continue like this untill we find median.
On Thu, Aug 5, 2010 at 6:37 AM, AlgoBoy manjunath.n...@gmail.com wrote:
travse array and check that if(a[i]==a[i+1]||a[i]==a[i+2]);
if more then n/2 no are there then that condition will satisfy ...adjust
with boundary condition
On Thu, Aug 5, 2010 at 6:36 AM, AlgoBoy manjunath.n...@gmail.com wrote:
an array in which n/2 elements are unique...and the remaning n/2
I think use bfs ...
On Thu, Jul 29, 2010 at 11:26 AM, irfan naseef irfannase...@gmail.comwrote:
On Thu, Jul 29, 2010 at 11:35 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
please explain q ..i didnt understand
On Thu, Jul 29, 2010 at 11:01 AM, irfan irfannase...@gmail.com
draw a line or equation of a line?
On Mon, Jul 12, 2010 at 4:38 PM, Anand anandut2...@gmail.com wrote:
2 coordinate points p(x,y)and q(x,y) are given and write an algorithm to
draw aline
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
@anand ..can you explain it more with example
On Mon, Jul 12, 2010 at 10:19 AM, Anand anandut2...@gmail.com wrote:
topological sort would cover every vertex once. The path given by
Topological sort would be the answer. We can also calculate the vertices
given by topological sort and compare
@amit..can you little explain this
On Mon, Jul 12, 2010 at 4:50 PM, Amir hossein Shahriari
amir.hossein.shahri...@gmail.com wrote:
this can be done in O(n) using DP:
for (i=n-1;i=0;i--){
dp[i]=max(dp[i+2],dp[i+3]); // usual
if (a[i]==a[i+1]) // excellent size 2
solution for topcoder all available but not others
On Sun, Jul 11, 2010 at 2:19 AM, venkat kumar svenkatkuma...@gmail.comwrote:
are solutions available for problems in
spoj,uva,codedhef,topcoder,etc.etc.?pls tell me
tnkyou
--
You received this message because you are subscribed to the
for sort you have to traverse array atleast once ..and after it some sorting
procedure will come.
On Fri, Jul 9, 2010 at 12:55 PM, Devendra Pratap Singh
dpsingh.ii...@gmail.com wrote:
plz write a code to
Sort n integer in the range 1 to n^2 in O(n)
--
You received this message because
it will be 1:1 because probability of guy is
1/2+1/2*1/2+1/2*1/2*1/2.=1
and girls and boys has same probability
On Sun, Jul 4, 2010 at 6:00 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:
yeah 1:1
On Sun, Jul 4, 2010 at 4:57 PM, Amit Jaspal amitjaspal...@gmail.comwrote:
it will be
We can do 4 type of treversal.
If we do inorder then we will get sorted array .If we do an inorder
traversal then we would get a sorted list which if we convert into a BST
would again become a list and we would loose out on the original structure
of the tree.
and same will be happen with post
34 matches
Mail list logo