Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions LiiNi-coder/202512/11 PGM 뉴스 클러스터링.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
```java
import java.util.*;

class Solution {
private static Map<String, int[]> map;
public int solution(String str1, String str2) {
map = new HashMap<String, int[]>();
pushSet(str1, 0);
pushSet(str2, 1);

int bunja = 0;
int bunmo = 0;
for(Map.Entry<String, int[]> entry: map.entrySet()){
int[] v = entry.getValue();
bunja += Math.min(v[0], v[1]);
bunmo += Math.max(v[0], v[1]);
}

if(bunmo == 0)
return 65536;

return (int)( (bunja /(float)bunmo) * 65536 );
}

private void pushSet(String str, int index){
char[] cs = str.toCharArray();
for(int i = 0; i < cs.length - 1; i++){
char a = cs[i];
char b = cs[i + 1];
if(!Character.isLetter(a) || !Character.isLetter(b))
continue;
a = Character.toLowerCase(a);
b = Character.toLowerCase(b);

String key = "" + a + b;

if(!map.containsKey(key))
map.put(key, new int[2]);

map.get(key)[index]++;
}
}
}

```