From c48048d6b9d610ba400280ac730f9787e401cff2 Mon Sep 17 00:00:00 2001 From: donghyeon95 Date: Sun, 29 Dec 2024 23:55:50 +0900 Subject: [PATCH] feat: Missing Number #235 --- missing-number/donghyeon95.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 missing-number/donghyeon95.java diff --git a/missing-number/donghyeon95.java b/missing-number/donghyeon95.java new file mode 100644 index 000000000..03985af52 --- /dev/null +++ b/missing-number/donghyeon95.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +// O(N) +class Solution { + public int missingNumber(int[] nums) { + Set numSet = Arrays.stream(nums).boxed().collect(Collectors.toSet()); + + for (int i=0; i