File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
src/com/algorithm2025/backjoon3/day004 Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .algorithm2025 .backjoon3 .day004 ;
2
+
3
+ import java .util .HashMap ;
4
+ import java .util .Map ;
5
+
6
+ public class Example20250626_Q_L_594 { //번외 letcode 594 Longest Harmonious Subsequence
7
+
8
+ public int findLHS (int [] nums ) {
9
+
10
+ Map <Integer , Integer > map = new HashMap <>();
11
+ int logset =0 ;
12
+
13
+ for (int i =0 ;i <nums .length ;i ++){
14
+ if (map .containsKey (nums [i ])){
15
+ map .put (nums [i ],map .get (nums [i ])+1 );
16
+ } else {
17
+ map .put (nums [i ],1 );
18
+ }
19
+ }
20
+
21
+ for (int key :map .keySet ()){
22
+ if (map .containsKey (key +1 )){
23
+ logset = Math .max (logset ,map .get (key )+map .get (key +1 ));
24
+ }
25
+ }
26
+
27
+ return logset ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ package com .algorithm2025 .backjoon3 .day004 ;
2
+
3
+ import java .util .Scanner ;
4
+
5
+ public class Example20250626_Q_L_704 { //번외 letcode 704 Binary Search
6
+ public int search (int [] arr ,int target ){
7
+
8
+ int low = 0 ;
9
+ int height = arr .length -1 ;
10
+ while (low <height ){
11
+ int mid = (low +height )/2 ;
12
+ if (arr [mid ]==target ){
13
+ return mid ;
14
+ } else if (arr [mid ]<target ){
15
+ low = mid +1 ;
16
+ } else {
17
+ height = mid -1 ;
18
+ }
19
+ }
20
+
21
+ return -1 ;
22
+
23
+ }
24
+
25
+ }
Original file line number Diff line number Diff line change
1
+ package com .algorithm2025 .backjoon3 .day004 ;
2
+
3
+ public class Example20250626_Q_L_744 { //번외 letcode 744 Find Smallest Letter Greater Than Target
4
+ public char nextGreatestLetter (char [] letters , char target ) {
5
+
6
+ for (char c :letters ){
7
+ if (c >target ){
8
+ return c ;
9
+ }
10
+ }
11
+ return letters [0 ];
12
+ }
13
+
14
+ }
You can’t perform that action at this time.
0 commit comments