From 20c75e3f5decf4b6160b169305b9b055804d1d82 Mon Sep 17 00:00:00 2001 From: Yuvraj15101999 <48157851+Yuvraj15101999@users.noreply.github.com> Date: Sun, 16 May 2021 20:20:15 +0530 Subject: [PATCH] Issue in the return of the CelebrityProblem Since the we are only assuming that the first person is the celebrity while returning first person as output , we should return the only thing that is remained in the stack after the check --- src/main/java/com/rampatra/arrays/CelebrityProblem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/rampatra/arrays/CelebrityProblem.java b/src/main/java/com/rampatra/arrays/CelebrityProblem.java index 8b7278ea..bb28fcc3 100644 --- a/src/main/java/com/rampatra/arrays/CelebrityProblem.java +++ b/src/main/java/com/rampatra/arrays/CelebrityProblem.java @@ -75,7 +75,7 @@ public static int findCelebrity(int[][] peoples) { } } - return firstPerson; + return possibleCelebrites.pop(); } public static void main(String[] args) {