Created
December 9, 2021 06:44
-
-
Save nphausg/8681c62c3748eef5849066d337b166df to your computer and use it in GitHub Desktop.
FindTheSmallestPositiveNumberMissing from an Sorted Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Created by nphau on 09/12/2021, 00:30 | |
| * Copyright (c) 2021 . All rights reserved. | |
| * Last modified 09/12/2021, 15:54 | |
| */ | |
| public int solution(int[] numbers) { | |
| Arrays.sort(numbers); | |
| int min = 1; | |
| for (int i : numbers){ | |
| if(i == min){ | |
| min ++; | |
| } | |
| } | |
| return min; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment