Hi,
As TC is over, so now I can submit the code of above prob:
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
public class MathContest
{
public int countBlack(String ballSequence, int repetitions)
{
int sl = ballSequence.length();
int l = sl*repetitions;
int a[] = new int[l];
for(int i=0;i<repetitions;i++)
{
for(int j=0;j<sl;j++)
{
if(ballSequence.charAt(j)=='W')
a[j+i*sl]=0;
else
a[j+i*sl]=1;
}
}
int count=0;
int i=0;
while(i<l-1)
{
if(a[i]==0)
{
for(int j=0;j<=(l-i-1)/2;j++)
{
int temp = a[j+i+1];
a[j+1+i]= a[l-1-j];
a[l-j-1] = temp;
}
}
else
{
for(int j=i+1;j<l;j++)
{
if(a[j]==0) a[j]=1;
else
a[j]=0;
}
count++;
}
i++;
}
if(a[l-1]==1)
count++;
return count;
}
Thanks,
Abhishek
On Tue, Apr 26, 2011 at 11:03 PM, Arpit Sood <[email protected]> wrote:
> @vaibhav he will be banned for sometime in topcoder if someone reports
> about this, you can count on that.....
>
>
> On Tue, Apr 26, 2011 at 10:42 PM, saurabh singh <[email protected]>wrote:
>
>>
>> Asking solution for a question 4m a live coding match is......
>> I am out of this topic.Apologies to anyone insulted 4m my side but i am
>> firm on wat i said.Leave the decision on the conscience of other readers.
>>
>> On Tue, Apr 26, 2011 at 10:08 PM, vaibhav shukla <[email protected]
>> > wrote:
>>
>>> I dont know y u ppl are so much concerned.He has just asked the
>>> question.Did any one answered it ??No,then y r u taking pain.
>>> and I dont know how is this a disgrace on spirit of coding ??Is asking
>>> a question a disgrace ?rubbish.
>>>
>>>
>>> On Tue, Apr 26, 2011 at 10:04 PM, radha krishnan <
>>> [email protected]> wrote:
>>>
>>>> May be he s innocent
>>>>
>>>>
>>>>
>>>> On Tue, Apr 26, 2011 at 10:02 PM, saurabh singh <[email protected]>wrote:
>>>>
>>>>> And sincerely hope no one helps him in near future too..........
>>>>>
>>>>> Disgrace on the spirit of coding
>>>>> On Tue, Apr 26, 2011 at 9:38 PM, radha krishnan <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Are u mad man ?
>>>>>> WTF ?
>>>>>> wats ur TC handle ?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Apr 26, 2011 at 9:22 PM, Aakash Johari <[email protected]
>>>>>> > wrote:
>>>>>>
>>>>>>> You can ask the solution after the contest. :)
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Apr 26, 2011 at 8:50 AM, Gunjan Sharma <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> @Kamlesh: In this world this thing is termed as cheating..... I wish
>>>>>>>> nobody helps u on this....
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Apr 26, 2011 at 9:17 PM, Saravanan T <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Post the question!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Apr 26, 2011 at 7:38 PM, kamlesh yadav <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> plaese be online at 8.30 pm today if possible and please help me.
>>>>>>>>>>
>>>>>>>>>> On Tue, Apr 26, 2011 at 7:19 PM, kamlesh yadav <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>> > hello friends
>>>>>>>>>> > i NEED UR HUMBLE SUPPORT
>>>>>>>>>> >
>>>>>>>>>> > I will post a question after an hour,
>>>>>>>>>> if
>>>>>>>>>> > anybody can solve it for me as early as possible (probably
>>>>>>>>>> within 45
>>>>>>>>>> > minutes), then please solve it and send it ti me. I urgently
>>>>>>>>>> need it
>>>>>>>>>> > my id [email protected]
>>>>>>>>>> >
>>>>>>>>>> > --
>>>>>>>>>> > You received this message because you are subscribed to the
>>>>>>>>>> Google Groups "Algorithm Geeks" group.
>>>>>>>>>> > To post to this group, send email to [email protected]
>>>>>>>>>> .
>>>>>>>>>> > To unsubscribe from this group, send email to
>>>>>>>>>> [email protected].
>>>>>>>>>> > For more options, visit this group at
>>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Kamlesh Kumar Yadav
>>>>>>>>>> MCA Department of Computer Science
>>>>>>>>>> Delhi University
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>>>> [email protected].
>>>>>>>>>> For more options, visit this group at
>>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>>> [email protected].
>>>>>>>>> For more options, visit this group at
>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Regards
>>>>>>>> Gunjan Sharma
>>>>>>>> Chairman IEEE Students Chapter IIT Roorkee
>>>>>>>> B.Tech IV year CSE
>>>>>>>>
>>>>>>>> Contact No- +91 9997767077
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> [email protected].
>>>>>>>> For more options, visit this group at
>>>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> -Aakash Johari
>>>>>>> (IIIT Allahabad)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> To unsubscribe from this group, send email to
>>>>>>> [email protected].
>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to [email protected].
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected].
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Saurabh Singh
>>>>> B.Tech (Computer Science)
>>>>> MNNIT ALLAHABAD
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> best wishes!!
>>> Vaibhav Shukla
>>> DU-MCA
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT ALLAHABAD
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Arpit Sood
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.