From 1cd9055dc6337fa7f43c09a728ffcda502a508e9 Mon Sep 17 00:00:00 2001 From: Jason House Date: Mon, 7 Jul 2025 19:12:19 -0400 Subject: [PATCH] Fixed possible NPE Swapped null check to first step in if statement. If null is true, won't NPE anymore. --- leetcode/bit-manipulation/MaximumProductOfWordLengths.java | 2 +- leetcode/two-pointers/RemoveDuplicatesFromSortedArray.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/leetcode/bit-manipulation/MaximumProductOfWordLengths.java b/leetcode/bit-manipulation/MaximumProductOfWordLengths.java index 256dfa43..1e7f2def 100644 --- a/leetcode/bit-manipulation/MaximumProductOfWordLengths.java +++ b/leetcode/bit-manipulation/MaximumProductOfWordLengths.java @@ -17,7 +17,7 @@ public class MaximumProductOfWordLengths { public int maxProduct(String[] words) { - if(words.length == 0 || words == null) { + if(words == null || words.length == 0) { return 0; } diff --git a/leetcode/two-pointers/RemoveDuplicatesFromSortedArray.java b/leetcode/two-pointers/RemoveDuplicatesFromSortedArray.java index 7e84e55a..124fb00f 100644 --- a/leetcode/two-pointers/RemoveDuplicatesFromSortedArray.java +++ b/leetcode/two-pointers/RemoveDuplicatesFromSortedArray.java @@ -9,7 +9,7 @@ public class RemoveDuplicatesFromSortedArray { public int removeDuplicates(int[] nums) { - if(nums.length == 0 || nums == null) { + if(nums == null || (nums.length == 0) { return 0; }