Wednesday 24 August 2011

String Puzzle


package com.test.p3;

/**
*
@author light
*
* Suppose we are given a string 000011112222.
* Make it 012012012012 in O(n) time and O(1) space.
*/

public class FindPattern {

public static void main(String args[])
{
String str="000011112222";
for(int i=0;i<str.length();i++)
{
System.out.print(i%(3));
}
}
}

No comments:

Post a Comment