Question 8 [15 marks) Write a class method compress(String str, int max) which replaces n consecutive occurrences of pat
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Question 8 [15 marks) Write a class method compress(String str, int max) which replaces n consecutive occurrences of pat
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)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!