Menu
Question Index
...


Write a program to get the most famous friend of the given person. The most famous friend is some one who has maximum number of friends.

Input (String, String) (For display purpose new line is shown as $) Output (String)
Ravi,Lokesh$Ravi,venkatesh$Ravi,Swetha$Swetha,Narayan$Narayan,Lakshmi$Lakshmi,Divya$Divya,Narayan$Ram,Divya$Sanjay,Ravi$Lokesh,Sanjay
personName is Narayan
Divya
Raju,Rani$Raju,Vikram$Raju,Abhijeet$Abhijeet,Rajesh$Rajesh,Saranya$Saranya,Tejaswini$Tejaswini,Manish$Saranya,Ramana$Ramana,Raju$Tejaswini,Rani
personName is Raju
Rani
Raju,Rani$Raju,Vikram$Raju,Abhijeet$Abhijeet,Rajesh$Rajesh,Saranya$Saranya,Tejaswini$Tejaswini,Manish$Saranya,Ramana$Ramana,Raju$Tejaswini,Rani
personName is Mahesh
null

class GetTheMostFamousFriend

{    public static void main(String s[])
    {
        String input = "Raju,Rani\nRaju,Vikram\nRaju,Abhijeet\nAbhijeet,Rajesh\nRajesh,Saranya\nSaranya,Tejaswini\nTejaswini,Manish\nSaranya,Ramana\nRamana,Raju\nTejaswini,Rani";
        System.out.println("The most famous friend of Rani is : " + getMostFamousFriend(input, "Rani"));

    }


public static String getMostFamousFriend(String friendsDetails, String personName) {
//Write code here to get the most famous friend of a given person.
}

//Write code here to create any additional methods.
}

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