Subscribe to:
Post Comments (Atom)
Write a python function, find_correct() which accepts a dictionary and returns a list as per the rules mentioned below. The input dictionary will contain correct spelling of a word as key and the spelling provided by a contestant as the value.
Write a python function, find_correct() which accepts a dictionary and returns a list as per the rules mentioned below. The input diction...
-
The Metro Bank provides various types of loans such as car loans, business loans and house loans to its account holders. Write a python pr...
-
Question: FoodCorner home delivers vegetarian and non-vegetarian combos to its customer based on order. A vegetarian combo costs Rs.120 pe...
-
Question: You have x no. of 5 rupee coins and y no. of 1 rupee coins. You want to purchase an item for amount z. The shopkeeper wants you ...
// Solution in JAVA
ReplyDeleteimport java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public class Assgn43 {
public static void main(String[] args)
{
ArrayList arg = new ArrayList(List.of(12,54,68,759,24,15,12,68,987,758,25,69));
System.out.println("ArrayList with duplicates: "+ arg);
Assgn43 duplist = new Assgn43();
duplist.findDuplicate(arg);
//duplist.removeDuplicate(arg);
}
public void findDuplicate(ArrayList arg)
{
ArrayList arrli = new ArrayList();
arrli = arg;
int count;
Iterator Itr = arrli.iterator();
HashSet arra = new HashSet();
while(Itr.hasNext())
{
int upVal = (Integer) Itr.next();
Iterator ptr = arrli.iterator();
count = 0;
while(ptr.hasNext())
{
int downVal = (Integer) ptr.next();
if(upVal == downVal) {
count++ ;
}
}
if(count > 1)
arra.add(upVal);
}
System.out.println("The List of duplicate elemnts is: "+ arra.toString());
}