diff --git a/2784. Check if Array is Good b/2784. Check if Array is Good new file mode 100644 index 0000000..0309a1a --- /dev/null +++ b/2784. Check if Array is Good @@ -0,0 +1,13 @@ +class Solution { + public boolean isGood(int[] nums) { + int n = nums.length; + Arrays.sort(nums); + + for (int i = 0; i < n - 1; i++) { + if (nums[i] != i + 1) + return false; + } + + return nums[n - 1] == n - 1; + } +}