Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the following method: COPYRIGHT public static String replacement(String ori, String r, String w, int N) COPYRIGHT COPY This method should replace upto the last
Implement the following method: COPYRIGHT public static String replacement(String ori, String r, String w, int N) COPYRIGHT COPY This method should replace upto the last N occurrences of the String r with String w if the total length of String w (number of occurrence of w in the resulting String X w.length() is less than 45%(inclusive) of the length of ori String; otherwise, you are going to replace upto the last N occurrences of w with r. If r or w is null or an empty String, return original String without any modification. If original String is null, return null. Otherwise, return a String after applying these rules. For example, replacement("Skiing is fun", "1", "ii",3) should return "Sking is fun" GHT COPYRIG replacement("AAABB","A","C",1) should return "AACBB" replacement("AAABB", "A","C", 2) should return "ACCBB" replacement("AAABB","A", "B",3) should return "AAAAA" Please use a comment line to record how long time you spent on this problem RIGHT
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started