Question
Java: Count the number of repetations of words in an ArrayList append that count and return that list. You need to implent a function countDeviceNames
Java:
Count the number of repetations of words in an ArrayList append that count and return that list. You need to implent a function countDeviceNames that takes an ArrayList as an input and returns an ArrayList
input ["switch","tv","switch","tv","switch","tv"]
output [switch, tv, switch1, tv1, switch2, tv2]
In this example as word switch is repeated we pick the next entry where it is repeated and append the count i.e how many times that word was present previously
More Exmaples
input ["switch","tv","switch","tv","switch","tv","radio"]
output [switch, tv, switch1, tv1, switch2, tv2, radio]
input ["switch","tv","switch","tv"]
output [switch, tv, switch1, tv1]
if words are not repeated we get the same output
input ["switch","tv"]
output [switch, tv]
please start after
import java.util.ArrayList; import java.util.Arrays; import java.util.List;
class Main { public static void main(String[] args) { }
public static List
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