Question 8 [15 marks) Write a class method compress(String str, int max) which replaces n consecutive occurrences of pat
Posted: Sun May 15, 2022 11:51 am
Question 8 [15 marks) Write a class method compress(String str, int max) which replaces n consecutive occurrences of pattern p by "@nkp", where '@' is an character with numeric value 64, n (>=2) is an integer value, p is the shortest) substring of str with repetition(s) and k is the length of p. The parameter max is the maximum length of pattern p which can be found by this method (i... maximum value of k). You can assume str contains letters only. For example, compress("abcbcbcdee", 4) returns "a@32bcd@21e". You may write additional methods if necessary (15)