Skip to content

Instantly share code, notes, and snippets.

@vsvankhede
Created July 18, 2019 11:20
Show Gist options
  • Save vsvankhede/5efef29269a7c8068b5c8bad3c2d48b7 to your computer and use it in GitHub Desktop.
Save vsvankhede/5efef29269a7c8068b5c8bad3c2d48b7 to your computer and use it in GitHub Desktop.
public class TwoPolitician {
public static class Pair {
String follower;
String following;
public Pair(String follower, String following) {
this.follower = follower;
this.following = following;
}
}
public static void main(String... args) {
String M = "Modi";
String O = "Obama";
String A = "Amit Shah";
String T = "Trump";
String R = "Rahul Gandhi";
Pair modiFollower1 = new Pair(O, M);
Pair modiFollower2 = new Pair(T, M);
Pair modiFollower3 = new Pair(R, M);
Pair modiFollower4 = new Pair(A, M);
Pair trumpFollower1 = new Pair(M, T);
Pair obamaFollower1 = new Pair(M, O);
Pair obamaFollower2 = new Pair(T, O);
Pair amitFollower1 = new Pair(M, A);
List<Pair> pairs = Arrays.asList(modiFollower1, modiFollower2, modiFollower3, modiFollower4,
trumpFollower1,
obamaFollower1,obamaFollower2,
amitFollower1);
boolean isFollowing = isFollower(pairs, R, A);
if(isFollowing) {
System.out.println("Correct following");
} else {
System.out.println("Incorrect! not following");
}
}
public static boolean isFollower(List<Pair> pairs, String polA, String polB) {
// write code here
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment