You have a array of 0's and 1's. e.g.
0001011101001010100101010101100111
Find the maximum contiguous subsequence of the above sequence so the
number of 0's and 1's in that subsequence are equal
Regards
Shashank Mani
--
You received this message because you are subscribed to the Google Groups
will an o(n^2) do ? , i have one in mind but will that suffice ?
anyways , here it goes
make array
a[array_length][2];
a[k][0] and a[k][1] will contain the no. of 0's and 1 till kth position.
just iterate twice to see where
a[i][0]-a[j][0]==a[i][1]-a[j][1]
can be maximized . meanwhile i am
maximum sub sequence whose sum is half of the sub sequence length.
On Tue, Jan 4, 2011 at 2:08 PM, bittu shashank7andr...@gmail.com wrote:
You have a array of 0's and 1's. e.g.
0001011101001010100101010101100111
Find the maximum contiguous subsequence of the above sequence so the
number of
it's exactly the same question as Buttons on codechef. search this forum ,
it have been discussed before
On Tue, Jan 4, 2011 at 4:13 PM, bittu shashank7andr...@gmail.com wrote:
There is a lock which is an N by N grid of switches. Each switch can
be in one of two states (on/off). The lock is
Assuming A[1..n]
i=1,j=n
calculate the initial sum and length of array
let it be s and l
now
if s l/2 then {
.if a[i]=1 then i++
.elseif a[j]=1 then j++
.else i++
}
if s l/2 then {
.if a[i]=0 then i++
.elseif a[j]=0 then j++
.else i++
}
if
@vishal
may be ur solution is correct
but if S very large then its not feasible to have matrix
On Wed, Dec 29, 2010 at 10:37 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
How will you divide and array of approx 100 elements into two sub sets
of 50 each such that the difference between both
Expecting solution is which is independent of S
On Wed, Dec 29, 2010 at 10:37 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
How will you divide and array of approx 100 elements into two sub sets
of 50 each such that the difference between both the subsets is the
minimum possible one . .
Why??? It doesn't help to solve problem. You are already have tree structure
with parent links. Taunt.
--
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
How about this algorithm:
1 sort the given array in ascending order
2 traverse from back that is greater to smaller
3 put the 1st read in arrayA and the 2nd read in arrayB
4 put the 3rd read in arrayB and the 4th read in arrayA (notice we
have reverse the order of putting the values)
5 repeat the
Generalization algorithm for the 8 - queens classical chess problem
On Jan 4, 5:43 am, bittu shashank7andr...@gmail.com wrote:
There is a lock which is an N by N grid of switches. Each switch can
be in one of two states (on/off). The lock is unlocked if all the
switches are on. The lock is
can someone please share a non-wiki link for tarjan algorithm for strongly
connected component . a video lecture link would be really nice ..
in case you have understanding of how it works , please share your thoughts
--
thanks
--mac
--
You received this message because you are subscribed to
http://forums.topcoder.com/?module=ThreadthreadID=687648messageID=1288196mc=6view=tree#1288196
hope it helps
On Tue, Jan 4, 2011 at 10:27 PM, MAC macatad...@gmail.com wrote:
can someone please share a non-wiki link for tarjan algorithm for strongly
connected component . a video lecture link
Yuckdonald's is considering opening a series of restaurants along
Quaint Valley Highway (QVH).The n possible locations are along a
straight line, and the distances of these locations from the start of
QVH are, in miles and in increasing order,m1;m2; : : : ;mn. The
constraints are as follows:
1)At
http://www.codechef.com/problems/RESN02/
someone please tell me how to approach this problem
--
Anuj Kumar
Third Year Undergraduate,
Dept. of Computer Science and Engineering
NIT Durgapur
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
There is a period. Find it and simulate the process only for this value.
--
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 email to
There may be long periods. So another approach should be applied.
--
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 email to
XOR is associative and commutative. So it's similar as + operator. First
turn the array into a n*1 vector. Each round of the operation could be
interpreted as a transition matrix A*vector.
For example, suppose you have a 4 elements array (a,b,c,d )intially, then
one round of operation could be
It can be solve using fast matrix exponentiation (modified version, based on
XOR operation).
Simulate XOR rounds one-by-one using variables, and you'll see that there is
pattern of matrix which is
move.
Start from vector B = [1, 1, 0, ..., 1]. Then do the following process:
next[i] = XOR
Your matrix has n*n dimensions. So to multiply it, you need to do O(N^3)
operations which is too slow for N=500. There is similar approach with a
vector multiplication instead of your idea. Btw, it is reached from the same
algorithm.
--
You received this message because you are subscribed to
Hi everyone,
I'm trying to implement a general method to find the roots of a cubic
equation. The conditions are: real coefficients, find all roots: real
and complex. I'm using the Cardano's Formula, available here:
ankur is right
this problem is similar to the problem of converting a matrix to zero matrix
On Tue, Jan 4, 2011 at 8:36 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
how are they similar ?
On Tue, Jan 4, 2011 at 8:31 PM, jennmeedo jennme...@gmail.com wrote:
Generalization algorithm for
problem has many properties like its a BST with parent pointer
we shud think of such a solution which uses its both property
If we will think abt the brute force recursive solution
its complexity will be O(no_of_nodes*height)
which can be made more efficient by putting some restrictions
in each
@ sunny
is there any reason for splitting the array in ur manner ??
and what abt the complexity ??
i think each time u exchange b/w A and B it takes O(n*n)
so u have complexity O(no_of_exchanges*n*n)
O(n^2) solution
sort the array...O(nlogn)
S=total sum
search for that continous
how can we make quick sort to run in O(logn) time in worst case??
--
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 email to
24 matches
Mail list logo