don't
use system.exit() please
Java code for above problem
class Main
{
public static void main(String args[])
{
String
str="qwwwwwwwwweeeeerrtyyyyyqqqqwEErTTT";
System.out.println("Original
string: "+str);
String
encoded_str=encode(str);
System.out.println("Encoded string:
"+encoded_str);
String
decoded_str=decode(encoded_str);
System.out.println("Decoded string:
"+decoded_str);
}
public static String decode(String str)
{
if(str.length()==0)
return "";
char ch=str.charAt(0);
if(Character.isDigit(ch))
{
int
count=ch-'0';
String
temp=get_str(str.charAt(1),count);
return
temp+decode(str.substring(2));
}
return
ch+decode(str.substring(1));
}
public static String get_str(char ch,int count)
{
if(count==0)
return "";
return
ch+get_str(ch,count-1);
}
public static String encode(String str)
{
String encoded_str="";
int len=str.length();
int i=0;
while(i<len)
{
int j=i+1;
while(j<len
&& str.charAt(j)==str.charAt(i))
j++;
int
count=j-i;
if(count>1)
encoded_str+=String.valueOf(count);
encoded_str+=str.charAt(i);
i=j;
}
return encoded_str;
}
}
Sample output
Mention in comments if any mistakes or errors are found. Thank you.
don't
use System.exit() please
use your own words, don't copy and paste, don't use handwriting, please. i need references please Discuss the applications of Binary Logistic Regression in Clinical Research using the case study given in the(Application of Binary Logistic Regression in Clinical Research) in a brief manner with a maximum length of two pages use your own words, don't copy and paste, don't use handwriting, please. i need references please use your own words, don't copy and paste, don't use handwriting, please. i...
use your own words, don't copy and paste, don't use handwriting, please. i need references please * Select an environmental health problem, in Saudi community. Outline of Environmental health report (1-2 pages) 1 The environmental health problem 1.1 What is the problem ? 1 point 1.2 Where is that problem? I point 1.3 When the problem happened? 1 point 2 Causes of the environmental health problem 2 points 3 Health effects of the problem Use references , 2 points 4...
** use your own words, don't copy and paste, don't use handwriting, please. i need your references URL Link please** ** use your own words, don't copy and paste, don't use handwriting, please. i need your references URL Link please** Q: Find out a food technical regulation and standards for any selected food items in Kingdom of Saudi Arabia (example- pickled fruits, pickled cucumber). Discuss the health effects about the food additives used on them // i need more details and...
Please, i need Unique answer, Use your own words (don't copy and paste) *Please, don't use handwriting. * i need References APA style Q1. What are the General purposes of communication?
Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use handwriting. How do Internet technologies help companies in building a customer-focused business?
Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use handwriting. * i need References APA style . What are the major food groups for diet? (1 Point)
use your own words, don't copy and paste, don't use handwriting, please. i need references please * Select an environmental health problem, in Saudi community. please DON'T talk about Desertification Outline of Environmental health report (1-2 pages) 1 The environmental health problem 1.1 What is the problem ? 1.2 Where is that problem? 1.3 When the problem happened? 2 Causes of the environmental health problem 3 Health effects of the problem Use references , 4 Solutions / mitigation measures Use...
use your own words, don't copy and paste, don't use handwriting, please. i need references please * Select an environmental health problem, in Saudi community. please DON'T talk about Desertification Outline of Environmental health report (1-2 pages) 1 The environmental health problem 1.1 What is the problem ? 1.2 Where is that problem? 1.3 When the problem happened? 2 Causes of the environmental health problem 3 Health effects of the problem Use references , 4 Solutions / mitigation measures Use...
use your own words, don't copy and paste, don't use handwriting, please. i need references please * Select an environmental health problem, in Saudi community. please DON'T talk about Desertification Outline of Environmental health report (1-2 pages) 1 The environmental health problem 1.1 What is the problem ? 1.2 Where is that problem? 1.3 When the problem happened? 2 Causes of the environmental health problem 3 Health effects of the problem Use references , 4 Solutions / mitigation measures Use...