We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 265a2fe commit 2de5c70Copy full SHA for 2de5c70
1 file changed
LiiNi-coder/202510/04 BOJ List of Unique Numbers.md
@@ -0,0 +1,33 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
8
+ int N = Integer.parseInt(br.readLine());
9
+ StringTokenizer st = new StringTokenizer(br.readLine());
10
+ int[] arr = new int[N];
11
+ for(int i = 0; i < N; i++){
12
+ arr[i] = Integer.parseInt(st.nextToken());
13
+ }
14
15
+ long result = 0;
16
+ int l = 0;
17
+ int MAX = 100000;
18
19
+ int[] freq = new int[MAX + 1];
20
+ for(int r = 0; r < N; r++){
21
+ freq[arr[r]]++;
22
+ while(freq[arr[r]] > 1){
23
+ freq[arr[l]]--;
24
+ l++;
25
26
+ result += (r - l +1);
27
28
29
+ System.out.println(result);
30
31
+}
32
33
+```
0 commit comments