Menu
Question Index
...


Write a program to find the most similar name to the given name. Assume that the most similar name is the one with minimum length difference. If there are more than one name with same length difference then choose the one with minimum ASCII code difference.

Input (List, String) Output (String)
[Ramesh, Rajubhai, Rathode], Raju Ramesh
[Arjun, Ravi, Karan], Varun Arjun
[Nihal, Mahal, Kamal, Jamal, Kalil], Saval Kalil
[Sekhar, Suman, Rajasehkar, Rupesh, Suresh], Rajesh Sekhar
[AAAAA, ZZ, ZZZZZZ], ZZZ ZZ
[RRR, PP, TTTT], TT PP
[KKK, MMM, LLL], JJ KKK

class SimilarNameUsingLengthAndAsciiCode

{    public static void main(String s[])
    {
        List names = new ArrayList();
        names.add("Nihal");
        names.add("Mahal");
        names.add("Kamal");
        String input = "Saval";
        System.out.println("The most similar name is : " + getMostSimilarName(names, input));

    }


public static String getMostSimilarName(List<String> listOfNames, String input) {
//Write code here to find the most similar name using the length difference and then ASCII code difference
}

//If required, write any additional methods here
}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App