There are a lot of simplifications you can make to get this problem
down to a manageable size.
First of all, notice that each of the four buttons inverts itsself. So
if you press it twice, you are back to the initial state. The order of
button pushes does not matter. Any order of the same button
in the circular array ABCDEABCCDE
The answer is 6 because the circular string starting from the element
A in the 6th position comes first in the dictionary formed from all
the possible strings of the circular array.
for ABCDEAABCCDA is 6
--
You received this message because you are subscribed
i believe you are asking for rank in lexicographic rotation
On Tue, Jul 26, 2011 at 11:52 PM, coder coder
i.code.program...@gmail.comwrote:
in the circular array ABCDEABCCDE
The answer is 6 because the circular string starting from the element
A in the 6th position comes first in the
would it make a difference if it wasnt a circular array?
On 26 July 2011 23:52, coder coder i.code.program...@gmail.com wrote:
in the circular array ABCDEABCCDE
The answer is 6 because the circular string starting from the element
A in the 6th position comes first in the dictionary formed
int getFirstIndexInLex(char arr[],int size)
{
int minindex=0,i;
for(i=1;isize;i++)
{
if(arr[i] arr[minindex])
minindex=i;
else if(arr[i]==arr[minindex])
minindex=checkmin(arr,size,minindex,i);
}
return minindex;
}
int checkmin(char
yes
--
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
@ankit
your answer is wrong for the test case ABCDEAABCCDA
--
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
There is a mistake in my code:
In the function
int checkmin(char arr[],int size,int i,int j)
after the while loop in the line
if(k==0)
It shud be :
if(k==size) instead of if(k==0)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
ankit your solution gives answer 11 for test case ABCDEAABCCDA ie
AABCDEAABCCD
Isn't solution is AABCCDAABCDE ie 6
--
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
@coder: my mistake. There is a typo in my code.
the condition is :
while(arr[i]==arr[j] ksize)
--
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,
@ankit still your solution is not giving the correct result for this test
case
--
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
@coder : No, my solution gives the correct answer. Check it out again !!
--
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
the answer should be 6 correct me if i am getting the question wrong
#includeiostream
using namespace std;
int checkmin(char arr[],int size,int i,int j)
{
int k=0;
while(arr[i]==arr[j] ksize)
{
i=(i+1)%size;
j=(j+1)%size;
k++;
}
if(k==size)
return i;
can u plz explain dis code?
On Wed, Jul 27, 2011 at 12:37 AM, coder coder
i.code.program...@gmail.comwrote:
the answer should be 6 correct me if i am getting the question wrong
#includeiostream
using namespace std;
int checkmin(char arr[],int size,int i,int j)
{
int k=0;
@coder :Got my mistake. There is a slight change in the checkmin function.
Actually I was returning the modified value of i and j. Following is the
correct code :
#includeiostream
using namespace std;
int checkmin(char arr[],int size,int i,int j)
{
int k=0,*m=i,n=j*;
while(arr[i]==arr[j]
thanx bro
--
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
#includecmath
#includecstdio
#includeiostream
#includestring
using namespace std;
#define ll long long int
#define INF 0x7fff
int mask(ll x,string str,ll dist)
{
ll re=INF,y=0,len;
len=str.size();
for(int i=0;ilen;i++)
if( !(x(1LLi)) || str[(i+dist)%len]re )continue;
#includecmath
#includecstdio
#includeiostream
#includestring
using namespace std;
#define ll long long int
#define INF 0x7fff
ll mask(ll x,string str,ll dist)
{
ll re=INF,y=0,len;
len=str.size();
for(int i=0;ilen;i++)
if( !(x(1LLi)) || str[(i+dist)%len]re )continue;
#includecmath
#includecstdio
#includeiostream
#includestring
using namespace std;
#define ll long long int
#define INF 0x7fff
ll mask(ll x,string str,ll dist)
{
ll re=INF,y=0,len;
len=str.size();
for(int i=0;ilen;i++)
if( !(x(1LLi)) || str[(i+dist)%len]re
http://geeksforgeeks.org/
On Jun 8, 4:07 pm, coder dumca coder.du...@gmail.com wrote:
I am last year student preparing for placements
can any one give some ebooks on data structure, algo etc. like beofre some
time , some one posted a book how to crack the coding interview that was
an
I need some more books specialy on algo ds and puzzles
On Wed, Jun 8, 2011 at 4:07 AM, coder dumca coder.du...@gmail.com wrote:
I am last year student preparing for placements
can any one give some ebooks on data structure, algo etc. like beofre
some time , some one posted a book how to
Try placementsindia.blogspot.com , it has a good collection of
problems specific to placements.
On Thu, Jun 9, 2011 at 12:23 PM, coder dumca coder.du...@gmail.com wrote:
I need some more books specialy on algo ds and puzzles
On Wed, Jun 8, 2011 at 4:07 AM, coder dumca coder.du...@gmail.com
This link has an online application which factors large numbers using
the Elliptic Curve method.
http://www.alpertron.com.ar/ECM.HTM
Try a value like
12991627363868130524522557049357159496792541860595064869631.
On my computer this application factors this number in 15 seconds.
Anything relying
Hi Don, I reposting my reply to you to all now..
The GNFS mentioned here is polynomial time as I got to understand from
wikipedia. I claim that the above algorithm is linear time.
I putting the proof here for correctness and linear time (warning its
big and messy). Also this one applies to the
Hi All,
I got a reply at another forum; here is the link for that
http://stackoverflow.com/questions/5581040/i-have-a-new-algorithm-to-find-factors-or-primes-in-linear-time-need-verificati
.. Don i believe you are correct.
Thanks
Harish
On Apr 7, 4:56 pm, harish hareeshgn...@gmail.com wrote:
The General Number Field Sieve is the fastest known method of
factoring large numbers, but the elliptic curve method may be faster
in some cases. Either one is much faster than your method.
Don
On Apr 6, 12:58 pm, harish hareeshgn...@gmail.com wrote:
Hi all,
I have developed an algorithm to
For the second question its not possible to do it in O(log n), as u need
O(n) time to read the elements itself.
You need to check your second question. There might be some constraints
associated with the arrays.
On 5/19/07, dor [EMAIL PROTECTED] wrote:
1. You can certainly do it in O(n
A. for finding the repeated elements in an array.
1. make a loop that goes thru from first to last element.
store the first array element into new array narr.
compare the array element from narr with new array element of step
1.
if array element from step 1 is
Hi,
You can try a similar technique...
Start at an arbitrary endpoint,
Set the number of open chords to zero,
Set the number of intersections to zero
Traverse the endpoints along the circle in one direction (made
possible by sorting radially)
{
If the endpoint is one that closes
Hi,
suppose the chords are represented as (x1,y1) (x2,y2) and x1 x2
then sort the chords according to x1 - o(nlogn)
then for each chords check with how many chords it intersects
(consider only x values),
logn for each key so another o(nlogn)
repeat the procedure with replacing x by y
30 matches
Mail list logo