Posts

String Compression

Image
up vote 1 down vote favorite Implement a method to perform basic string compression using the counts of repeated characters. For example, the string "aabcccccaaa" would become "a2b1c5a3". If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the string has only uppercase and lowercase letters (a - z). My solution is: GitHub public class StringCompression { public static String compress(String input) { if (input == null) { return null; } StringBuilder output = new StringBuilder(); char prevChar = input.charAt(0); int lengthSoFar = 1; for (int index = 1; index < input.length(); index++) { char currentChar = input.charAt(index); if (pre...

What is difference between participle phrases and ellipsis of subject + be in adverb phrases?

Image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0; } up vote 2 down vote favorite 1 When invited, she gladly said yes. In the above sentence, my book says the sentence is formed because ‘she was’ is omitted. And the sentence is the example of ellipsis of the same subject + be in the adverb phrase. Then what is difference with participle phrase? The above sentence cannot be seen as an example of a participle phrase? Help me grammar share | improve this question asked Nov 20 at 0:54 Yun 11 1 New cont...