From eefe47797c8bf4426b45a49ae95d7dab4ae90f87 Mon Sep 17 00:00:00 2001 From: Anuj Negi <66074635+anujnegi341@users.noreply.github.com> Date: Tue, 4 Aug 2020 00:16:02 +0530 Subject: [PATCH] update noble integer Earlier solution was not working for test cases like {-4, -2, 0, -1, -6} which has 0 as max value and also nos greater than 0 are 0. But after sorting when the loop iterates, it may sometimes skip 0 when the digit after array is 0( as A[i]==A[i+1] continue , skips this 0 ). You may check this on interviewbit. --- Array/Noble Integer | 1 + 1 file changed, 1 insertion(+) diff --git a/Array/Noble Integer b/Array/Noble Integer index 105f37f..e0fbdaa 100644 --- a/Array/Noble Integer +++ b/Array/Noble Integer @@ -9,6 +9,7 @@ If such an integer is found return 1 else return -1. int Solution::solve(vector &A) { int n=A.size(); sort(A.begin(),A.end()); + A.push_back(INT_MAX); for(int i=0;i