Write a python function find_duplicates(), which accepts a list of numbers and returns another list containing all the duplicate values in the input list. If there are no duplicate values, it should return an empty list.


1 comment:

  1. // Solution in JAVA

    import 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());
    }

    ReplyDelete

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...