You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package algo;
import java.util.HashSet;
import java.util.Set;
public class Solution {
public int solution(String[][] clothes) {
int answer = 1;
Set<String> set = new HashSet<>();
// 총 몇종류의 의상이 있는가 확인
for (int i = 0; i < clothes.length; i++)
{
set.add(clothes[i][1]);
}
String[] kinds = new String[set.size()];
int count = 0;
for (String s : set)
{
kinds[count++] = s;
}
int[] kinds_count = new int[set.size()];
//각각 clothes 돌면서 의상에 해당하는 index값 ++
for (int i = 0; i < clothes.length; i++)
{
for (int j = 0; j < kinds.length; j++)
{
if (clothes[i][1].equals(kinds[j])) // String 은 레퍼런스타입 ==비교가아니다
{
kinds_count[j]++;
}
}
}
for (int i = 0; i < kinds_count.length; i++) {
answer *= (kinds_count[i] + 1);
}
return answer-1;
}
}
The text was updated successfully, but these errors were encountered: