목록알고리즘 (35)
알맹이방
import java.util.ArrayList; import java.util.Collections; class Solution { ArrayList answers = new ArrayList(); void dfs(String begin, String[][]tickets, int count, String answer, boolean[]visited){ if(count==tickets.length){ answers.add(answer); return; } for(int i = 0; i
class Solution { static int sum_count = Integer.MAX_VALUE; //최솟값을 찾기 위한 count void dfs(boolean[] visited, String target, String[] words, String begin, int count){ //target 이라면 count가 sum_count보다 작으면 갱신해줌 if(begin.equals(target)){ if(sum_count>count){ sum_count=count; } return ; } for(int i = 0; i
import java.util.Arrays; import java.util.Comparator; class Solution { public String solution(int[] numbers) { String answer = ""; String[] str = new String[numbers.length]; for(int i = 0 ; i
#include #include #include using namespace std; int solution(vector clothes) { map strMap; for(vector elem : clothes){ strMap[elem[1]]+=1; } int result =1; map ::iterator iter; for(iter = strMap.begin(); iter!=strMap.end(); iter++){ result *= iter->second+1; } result--; return result; }