1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
cricket20 [7]
4 years ago
7

Write a method called compress that takes a string as input, compresses it using rle, and returns the compressed string. case ma

tters - uppercase and lowercase characters should be considered distinct. you may assume that there are no digit characters in the input string. there are no other restrictions on the input - it may contain spaces or punctuation. there is no need to treat non-letter characters any differently from letters.
Computers and Technology
1 answer:
MaRussiya [10]4 years ago
5 0
<span>public static String compress (String original) { StringBuilder compressed = new StringBuilder(); char letter = 0; int count = 1; for (int i = 0; i < original.length(); i++) { if (letter == original.charAt(i)) { count = count + 1; } else { compressed = count !=1 ? compressed.append(count) : compressed; compressed.append(letter); letter = original.charAt(i); count = 1; } } compressed = count !=1 ? compressed.append(count) : compressed; compressed.append(letter); return compressed.toString(); }</span>
You might be interested in
How do you enter the command prompt on Chromebook
Step2247 [10]

1) Go through the standard Chrome OS login screen (you'll need to setup a network, etc) and get to the web browser. It's OK if you login as guest.

2) Press [ Ctrl ] [ Alt ] [ T ] to get the crosh shell.

3) Use the shell command to get the shell prompt.

3 0
3 years ago
What is the value of the variable phones after the execution of the following code? phones = {'John': '5555555', 'Julie' : '7777
uysha [10]

Answer:

phones = {'John': '1234567', 'Julie' : '7777777'}

Explanation:

In the code given in the question phones dictionary contains contains two keys John and Julie and have the values '5555555' and '7777777' respectively. Now in the code the key John in the dictionary phones is assigned the value '1234567' .So the value corresponding to the key John becomes '1234567'.

3 0
4 years ago
Which of the following activities can cause data to be damaged or lost?
jekas [21]
Illegal access to a system
3 0
4 years ago
Give two reasons why cloud computing could be detrimental to a company.
dimulka [17.4K]

Security/Insider threats.

As much as cloud computing is good for your organization, just know that someone is looking after your data. The cloud provider does everything for you from maintenance to managing security. The bigger picture here is that users are entrusting their data to someone else. Although the work of cloud providers is to ensure that your data is safe, some are not always looking after your best interests.

Cyber-attacks.

Any time your data is stored on the cloud, you are at a higher risk of cyber-attack. Vulnerabilities such as DDoS attacks might occur and this single point of failure is in the cloud. As cloud computing continues to become more sophisticated, so do cyberattacks. As much as the security is right, hackers will go to any lengths to penetrate the systems.  


3 0
4 years ago
The __________ energy in food is changed into mechanical energy by your muscles.
qwelly [4]
The chemical energy in food is transformed into mechanical energy through a process called respiration. This isn't really a computers and technology question though. Try Biology next time.
4 0
3 years ago
Other questions:
  • Your Economics teacher has asked you to create a chart showing how supply and demand affects the price of gasoline. Which applic
    13·2 answers
  • ___ Jacking is a crime that takes place when a hacker misdirects URL to a different site. The Link Itself Looks Safe, But the us
    11·1 answer
  • What is the output of the following program? #include using namespace std; class TestClass { private: int val; void showVal() {
    5·1 answer
  • What is the primary reason that organizations change their structure through downsizing, outsourcing, and offshoring as a means
    14·1 answer
  • Memory cache is referred to as ______. A. SRAM c. SROM b. DRAM d. DROM
    11·1 answer
  • Which procedure is recommended when cleaning inside a computer? Clean the hard drive heads with a cotton swab. Hold the CPU fan
    9·1 answer
  • Let X and Y be two decision problems. Suppose we know that X reduces to Yin polynomial time. Which of the following statements a
    14·1 answer
  • The code on the side is a software solution to the mutual exclusion problem for two processes. It shares two variables:
    11·1 answer
  • Which online note-taking device allows students to clip a page from a website and reuse it later?
    13·2 answers
  • What is the meaning of FTTH
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!