given array-
1 0 0 1 1 1 0 1 0 1
for our convenience lets replace 0 by -1
array becomes
1 -1 -1 1 1 1 -1 1 -1 1
take another array count which which represents the sum till that index
sum array becomes
1 0 -1 0 1 2 1 2 1 2 //count array
now make an important
complexity O(n)
extra space O(n)
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99
On Thu, Sep 29, 2011 at 11:52 AM,
@Amol +1
On Thu, Sep 29, 2011 at 11:52 AM, Amol Sharma amolsharm...@gmail.comwrote:
given array-
1 0 0 1 1 1 0 1 0 1
for our convenience lets replace 0 by -1
array becomes
1 -1 -1 1 1 1 -1 1 -1 1
take another array count which which represents the sum till that index
sum
O/P should be 00111010 and sub array is exclusive of start index, inclusive
of end index.
Nice solution
On Thu, Sep 29, 2011 at 11:58 AM, UTKARSH SRIVASTAV usrivastav...@gmail.com
wrote:
@Amol +1
On Thu, Sep 29, 2011 at 11:52 AM, Amol Sharma amolsharm...@gmail.comwrote:
given array-
1
Can anyone tell me about tally solutions pvt ltd.
how is the company and growth in it..
what all is asked in interviews..
--
Regards
Chunky Garg
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@AMOL i want array index i.e i to j that will be max subarry which has equal
no of zero and one's
but i think ur soln is not providing this
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Impossible to solve in O(n) I suppose
On Thu, Sep 29, 2011 at 12:34 PM, kartik sachan kartik.sac...@gmail.comwrote:
@AMOL i want array index i.e i to j that will be max subarry which has
equal no of zero and one's
but i think ur soln is not providing this
--
You received this message
@kartik...try to implement the algo using pen and paper take 2-3 extra
variables for storing index also along with the variable max.the same
algo will also give you the required subarray indexes along with its
length...
--
Amol Sharma
Third Year Student
Computer Science and Engineering
ok amol i will do it..but i am unable to convience myself that
this algo will give the desire result
--
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
sachan!!amol ke rum par jaakar pooch le.
On Thu, Sep 29, 2011 at 1:10 PM, kartik sachan kartik.sac...@gmail.comwrote:
ok amol i will do it..but i am unable to convience myself that
this algo will give the desire result
--
You received this message because you are subscribed to
Algorithm Kadane
http://www.algorithmist.com/index.php/Kadane%27s_Algorithm
http://www.cs.ucf.edu/~reinhard/classes/cop3503/lectures/AlgAnalysis04.pdf
http://struts2spring.wordpress.com/2009/11/02/finding-the-maximum-contiguous-subsequence-in-a-one-dimensional-array/
Wladimir Araujo Tavares
First,
you need change 0 to -1
Wladimir Araujo Tavares
*Federal University of Ceará http://lia.ufc.br/%7Ewladimir/
Homepage http://lia.ufc.br/%7Ewladimir/ |
Maratonahttps://sites.google.com/site/quixadamaratona/|
*
On Thu, Sep 29, 2011 at 7:35 AM, Wladimir Tavares wladimir...@gmail.comwrote:
@asit dhal,
in order of any BST is increasing order.
so required is only either preorder/postorder
surender
On Tue, Sep 27, 2011 at 12:42 AM, Gene gene.ress...@gmail.com wrote:
Here is a little program to show how it works. It's a nice little
problem. There is also a coding with recursion.
Given a sorted Array of infinite length.. what is the most optimum way
to search for an element. We hane no idea about its length..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
*search for elements at 2^0 , 2^1, 2^2 and so on ... *
*
*
*
*regards
- Sumit Kumar Pathak
(Sumit/ Pathak/ SKP ...)
*Smile is only good contagious thing.*
*Spread it*!
On Thu, Sep 29, 2011 at 5:29 PM, pooja pooja27tan...@gmail.com wrote:
Given a sorted Array of infinite length.. what is
hey dude plz post the written test question as much as u
remeberneded urgent ..plz post
On Sep 24, 8:26 pm, Deoki Nandan deok...@gmail.com wrote:
congrats buddy
On 23 September 2011 17:31, siddharth srivastava akssps...@gmail.comwrote:
Hi
Congrats
What did you answer for
cdoc visited anywhere?
tell me details?
Regards
SOURABH KUMAR JAIN
NIT RAIPUR
--
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 search for element T in array A[], start at a point p 0.
If A[p] T, do a binary search on range 0..p.
Otherwise set p = 1 + p * (T - A[0]) / (A[p] - A[0]).
Repeat until A[p] = T. Then the current and previous values of p are
an interval containing T (if T is in A).
Do a binary search on that
mmm... i dont remember the questions but these are the 1s i faintly
remember:
1. semaphore based qs
2. a question from theory of computation
3. some questions on the big O-notation.
4. b-tree vs b+-tree
5. some questions on unix
6. http,tcp based qs..
well sorry but these r da 1s i m able 2
Is the array Sorted ?
On Thu, Sep 29, 2011 at 4:56 PM, raju nikutel...@gmail.com wrote:
Given an integer array. { 1,2,3,4,5 }
Compute array containing elements
120,60,40,30,24 (2*3*4*5,1*3*4*5, 1*2*4*5, 1*2*3*5, 1*2*3*4)
We shouldn't use division operator( / )
Time complexity O(n) ..
maintain two arrays one left array having value left[i] =
a[0]*a[1]*a[2].a[i-1] and one right array having value
right[i]=a[i+1]*[i+2]a[n] and then to get
ans[i]...ans[i]=left[i]*right[i]
On Thu, Sep 29, 2011 at 8:16 PM, Ankur Garg ankurga...@gmail.com wrote:
Is the array Sorted ?
congratzwat's d package which they offered in your campus?
On Thu, Sep 29, 2011 at 7:13 PM, rahul sharma rahul23111...@gmail.comwrote:
hey dude plz post the written test question as much as u
remeberneded urgent ..plz post
On Sep 24, 8:26 pm, Deoki Nandan deok...@gmail.com wrote:
whats the running time? isn't it O(n2) ?
On Thu, Sep 29, 2011 at 8:54 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:
maintain two arrays one left array having value left[i] =
a[0]*a[1]*a[2].a[i-1] and one right array having value
right[i]=a[i+1]*[i+2]a[n] and then to get
//use dynamic programming approach
//it is O(n) time and O(1) space
#includestdio.h
#define N 5
void main()
{
int a[N]={1,2,3,4,5},i;
int prod1[N];
int p=1;
for(i=0;iN;++i)
{
prod1[i]=p;
p*=a[i];
}
int prod2[N];
p=1;
for(i=N-1;i=0;--i)
{
prod2[i]=p;
p*=a[i];
}
int products[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@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
may be bcoz they(auto) are stored in stack
On Thu, Sep 29, 2011 at 10:05 PM, tech rascal techrascal...@gmail.comwrote:
--
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
Guys does any one hve the idea about INTEL interview process for CS students
?? The area they focus and types of question they ask .
If any have any idea plz help !
thnks
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
The global and the static variables are stored in the data section.
But the only legitimate answer that comes to my mind is that the makers
believed there language will be used by smart coders so they left it for the
programmers to fix.
While the java makers believed somewhat different so they
u can use any lang .
perl python etc .
On Thu, Sep 29, 2011 at 10:57 AM, prasanth n nprasnt...@gmail.com wrote:
c++ and java ll be given more preference
On Mon, Sep 26, 2011 at 5:59 PM, abhishek abhishek.ma...@gmail.comwrote:
c,c++ ,java
On Sep 26, 4:15 pm, Akash Mukherjee
bhai yaarsizeof operator use kar ke dekh le na...:P
read about virtual pointer(virtual table) and inheritance
On Thu, Sep 29, 2011 at 8:55 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:
how does virtual class and virtual function affect class size
any good link?
--
There are two linked list of length m and n. There is some common data
at the end of both. Find the starting position in both the linked
list. I could suggest two methods
1) Reverse the list and check .
2) Use recursion to go to the last element and move back from there.
Is there any other way ?
consider the length of list1 is 7(ie m) and length of list2 is 5 (ie n)..now
find (m-n) ie 7-5=2..since length of list2 is smaller than list1,,have a
pointer pointing to the head of the list2 and move that pointer (m-n)
positions ie (here 2 positions)..now have a pointer pointing to the head of
How do you deduce number of multiplication that when we perform a^b
function using dividing the exponent by 2 at each stage to be log b?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Because a^b = (a*a)^(b/2), so each multiplication reduces the exponent
by half. Therefore the number of multiplications is (roughly) log2 b.
int pow(int a, int b)
{
int result = a;
while(b 1)
{
result *= (b1) ? a*result : result;
b = 1;
}
return result;
}
You can see that a^16
you can use _start function in c and then compile with gcc -nostartfile
On Mon, Sep 19, 2011 at 2:39 PM, Prakash D cegprak...@gmail.com wrote:
in c/c++
without main function how to write a compilable code?
for example printing a string
On Tue, Sep 20, 2011 at 12:15 AM, hary rathor
I think that it will fail if the value of the coins can be more than
50001.
Don
On Sep 29, 12:35 pm, manish patel manispatel...@gmail.com wrote:
http://www.spoj.pl/problems/PIGBANK/
please suggest some test case where it fails ...
[code]
#includestdio.h
main()
{ int t=0,n,e,f,i,j;
plz do tell..
i also need sm intervw questions at the earliest..
Sahil Garg
Computer Engineering
Delhi College of Engineering
On Thu, Sep 29, 2011 at 12:26 PM, Chunky Garg g.chunkyg...@gmail.comwrote:
Can anyone tell me about tally solutions pvt ltd.
how is the company and growth in it..
in ELF compatible binaries it's also possible to use .ctors / .dtors
not sure whether PES has similar sections but I believe it does.
On Thu, Sep 29, 2011 at 3:42 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:
you can use _start function in c and then compile with gcc -nostartfile
On
void main()
{
void *ptr;
char *a='A';
char *b=TAN;
int i=50;
ptr=a;
ptr=(*char)malloc(sizeof(a));
printf(%c,*ptr);
ptr=i;
ptr=(*int)malloc(sizeof(i));
printf(%d,++(*ptr));
ptr=b;
ptr=(*char)malloc(sizeof(b));
printf(%c,++(*ptr));
}
Ans: A51AN
Please explain the output..
Doesnt this line
void main()
{
void *ptr;
char *a='A';
char *b=TAN;
int i=50;
ptr=a;
ptr=(*char)malloc(sizeof(a));
printf(%c,*ptr);
ptr=i;
ptr=(*int)malloc(sizeof(i));
printf(%d,++(*ptr));
ptr=b;
ptr=(*char)malloc(sizeof(b));
printf(%c,++(*ptr));
}
ptr=(*char)malloc(sizeof(a));
Ans: A51AN
Please explain the
This is the question : https://hs.spoj.pl/problems/HS11DIVS/ [ Count the
numbers ! - HS11DIVS ]
And here is my attempt : http://ideone.com/yynjH
Now , my problem is that the code works fine with small numbers ( even with
1 ) , but with larger number , time limit exceeds. How to make it
i think you can avoid calculating sumOfDigits(a) each time. Similarly
compute for all the values directly.
On Fri, Sep 30, 2011 at 1:11 AM, .itoa nitm...@gmail.com wrote:
Yeah , that is exactly what my question is. How to optimize ?
--
You received this message because you are subscribed to
that's a brute force approach, obviously it won't work.
On Fri, Sep 30, 2011 at 12:52 AM, .itoa nitm...@gmail.com wrote:
This is the question : https://hs.spoj.pl/problems/HS11DIVS/ [ Count the
numbers ! - HS11DIVS ]
And here is my attempt : http://ideone.com/yynjH
Now , my problem is that
check this http://www.geeksforgeeks.org/archives/7527
time O(n)
space O(n)
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
sumOfDigits has to be called for ALL values. we need to check sum for all
possible values which are divisible by x.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
yes, you have already calculated it for first value... so need not compute
it again
On Fri, Sep 30, 2011 at 1:21 AM, .itoa nitm...@gmail.com wrote:
sumOfDigits has to be called for ALL values. we need to check sum for all
possible values which are divisible by x.
--
You received this
are the algorithm instance always a sequence incremented by one?
On Thu, Sep 29, 2011 at 8:26 AM, raju nikutel...@gmail.com wrote:
Given an integer array. { 1,2,3,4,5 }
Compute array containing elements
120,60,40,30,24 (2*3*4*5,1*3*4*5, 1*2*4*5, 1*2*3*5, 1*2*3*4)
We shouldn't use division
Hi Ravi IVP visited in PEC on 29th so you can ask any of the CSE or IT
guys who have given the exam.. I haven't given it otherwise I would
have let you know the procedure.. Though there was a written test
followed by essay writing and then a Technical and HR interview..
Ankur Mittal
On Sep 28,
Given array A.
Compute array B such that
B[0] = 1;
for(i = 1; i n; i++)
B[i] = B[i-1]*A[i-1]
now,
mul = 1;
for (i = n-2; i =0; i--){
mul = mul*A[i];
B[i] = B[i]*mul;
}
On Fri, Sep 30, 2011 at 2:18 AM, Hatta tmd...@gmail.com wrote:
are the algorithm instance always a sequence
sorry, one mistake...
mul = mul*A[i];
it should be
mul = mul*A[i+1]
On Fri, Sep 30, 2011 at 2:57 AM, Piyush Grover piyush4u.iit...@gmail.comwrote:
Given array A.
Compute array B such that
B[0] = 1;
for(i = 1; i n; i++)
B[i] = B[i-1]*A[i-1]
now,
mul = 1;
for (i = n-2; i =0;
@Don ... optimal one ... +1
On Sep 29, 7:32 pm, Don dondod...@gmail.com wrote:
To search for element T in array A[], start at a point p 0.
If A[p] T, do a binary search on range 0..p.
Otherwise set p = 1 + p * (T - A[0]) / (A[p] - A[0]).
Repeat until A[p] = T. Then the current and previous
@Don, Ankuj. I believe that Don's algorithm uses precisely
floor{log_2(b)) + (the number of one bits in b) - 1.
Dave
On Sep 29, 1:38 pm, Don dondod...@gmail.com wrote:
Because a^b = (a*a)^(b/2), so each multiplication reduces the exponent
by half. Therefore the number of multiplications is
Why don't you post a code that compiles ?
On Fri, Sep 30, 2011 at 12:41 AM, Brijesh brijeshupadhyay...@gmail.comwrote:
void main()
{
void *ptr;
char *a='A';
char *b=TAN;
int i=50;
ptr=a;
ptr=(*char)malloc(sizeof(a));
printf(%c,*ptr);
ptr=i;
ptr=(*int)malloc(sizeof(i));
Make two conditions for even and odd power. and use it to make solve
higher power
That could be solved in log b time
.
On 30-Sep-2011 4:12 AM, Dave dave_and_da...@juno.com wrote:
@Don, Ankuj. I believe that Don's algorithm uses precisely
floor{log_2(b)) + (the number of one bits in b) -
Take two array... one will take care of left products... and othr will take
care of right product.. at any index left[i]=A[i-1]*left[i-1] starting
from left and right[i]= A[i+1]*right[i+1] starting frm right……
--
You received this message because you are subscribed to the Google Groups
@don we dnt hve ny info about arrangement...
--
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
Ptr cannot be used to allocate block of memory
.. void pointer use only to store address...
--
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
@prasanth but how can u know that it will start after the difference
of the number of nodes (m-n) . they may be similar even after one
element also ??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@annarao : as the common data is at the end of the linked lists so the
length of common data can not be greater than the length of shorter linked
list . so i think prasanth is right !!
--
*Partik Madan*
Computer Engg.
NIT Kurukshetra
--
You received this message because you are subscribed
@partik oh i forgot it thank u for ur clarification..
--
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
@Ankuj Gupta: your algo wont work
see,what happens when ur algo run.
list1 1-2-3-4-5-6
list2 9-8-4-5-6
reverse list 1
list1 6-5-4-3-2-1
6-5-4
^
|
list2 8-9
reverse list 2
list1 6-5-4-9-8
list2 4-9-8
Thank you,
Sid.
On Fri, Sep 30, 2011 at 9:37
i never heard about the company called cdoc
it may be cdac or cdot
Thank you,
Sid.
On Thu, Sep 29, 2011 at 7:48 PM, sourabh jain sourabhjain...@gmail.com wrote:
cdoc visited anywhere?
tell me details?
Regards
SOURABH KUMAR JAIN
NIT RAIPUR
--
You received this message because
find length of linked list 1 say m
find length of linked list2 say n
take mod(m-n) say k
traverse k nodes in bigger lis
after that both listts one position at a time until the pointers are equal
On Fri, Sep 30, 2011 at 9:34 AM, partik madan partikma...@gmail.com wrote:
@annarao : as the common
ptr is givenc char addrsss so print A
ptr given int address but ++(*ptr) increments that int val so it goes 51
next ptr contains char address of char but i think ++(*ptr) gives ua
insetead un an
On Fri, Sep 30, 2011 at 9:24 AM, praveen raj praveen0...@gmail.com wrote:
Ptr cannot be used to
n in last it prints an of o/p a51an but only %c used so i thhink
somethng wrngexplain nyone plz
On Fri, Sep 30, 2011 at 10:34 AM, rahul sharma rahul23111...@gmail.comwrote:
ptr is givenc char addrsss so print A
ptr given int address but ++(*ptr) increments that int val so it goes
what is c style string??n wats diff b/w c and c++ strings
representtaion..
--
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
*UPDATED *the first() function. Instead of using a loop , using m=a%x and a
= a-m+x to find the first divisible number.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
67 matches
Mail list logo