From 2de5c70ddba1cf672322ede4df4ee204de95f318 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Sat, 4 Oct 2025 23:14:46 +0900 Subject: [PATCH] =?UTF-8?q?[20251004]=20BOJ=20/=20G4=20/=20List=20of=20Uni?= =?UTF-8?q?que=20Numbers=20/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../202510/04 BOJ List of Unique Numbers.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 LiiNi-coder/202510/04 BOJ List of Unique Numbers.md diff --git a/LiiNi-coder/202510/04 BOJ List of Unique Numbers.md b/LiiNi-coder/202510/04 BOJ List of Unique Numbers.md new file mode 100644 index 00000000..10805af4 --- /dev/null +++ b/LiiNi-coder/202510/04 BOJ List of Unique Numbers.md @@ -0,0 +1,33 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + StringTokenizer st = new StringTokenizer(br.readLine()); + int[] arr = new int[N]; + for(int i = 0; i < N; i++){ + arr[i] = Integer.parseInt(st.nextToken()); + } + + long result = 0; + int l = 0; + int MAX = 100000; + + int[] freq = new int[MAX + 1]; + for(int r = 0; r < N; r++){ + freq[arr[r]]++; + while(freq[arr[r]] > 1){ + freq[arr[l]]--; + l++; + } + result += (r - l +1); + } + + System.out.println(result); + } +} + +```