abhishek4615
BAN USERpublic class StringT9 {
public static void main(String args[]){
//String input="22233#23";
String input="2#22#44#444#7777#44#33#55#8";
char[] in=input.toCharArray();
char prev,curr = 0;
prev=in[0];
int count=0;
//to find change in sequence
for(char i:in){
curr=i;
if(curr==prev)
{
count++;
prev=curr;
}
else
{
printChar(prev,count);//if prev is not same as curr,
// call helper function with current count
count=1;
prev=curr;
}
}
if(prev==curr)//corner case
{
printChar(prev,count);
}
}
private static void printChar(char prev, int count) {
//to handle space
if(prev=='#')
{
System.out.print(" ");
return;
}
if((prev=='8'))//special case of 4 char in 7 and 9
{
int b=Character.getNumericValue(prev);
char a= (char) ((66+((b-2)*3))+count-1);
System.out.print(a);
return;
}
//normal key presse
int b=Character.getNumericValue(prev);
char a= (char) ((65+((b-2)*3))+count-1);
System.out.print(a);
}
}
- abhishek4615 May 13, 2015
RepTristaRJohn, Reverse Engineering and System Developer at BT
I am an Ophthalmic medical assistant in bluefield USA, I assist in retinal exams and procedures. Referred patients to outside ...
Repjuliaaperez05, Cloud Support Associate at ABC TECH SUPPORT
I Performed extensive web research to collect pertinent data and gather images related to the assigned articleIts act of writing ...
Repraginieharris, IIT Exam at Altera
I am Ragini, and I have lived in Washington for 2 years. My current job is Web Designer in Corinthian ...
RepAlmaRJude, Quality Assurance Engineer at Brocade
I am Alma from Livermore USA, I also enjoy reading – my favourite topics being social history, the development and use ...
Repmarywwaldrop7, Computer Scientist at Chelsio Communications
I am Mary ,working in the field of training and development coordinator for three years, focusing on teaching English as ...
- abhishek4615 July 07, 2015