알고리즘 코드카타
select customer_id
from Customer
group by customer_id
having count(distinct product_key) >= (
select count(distinct product_key) as count
from Product
);
class Solution {
public String solution(String s) {
StringBuilder answer = new StringBuilder();
String[] words = s.split(" ", -1);
for (String word : words) {
if(word.isEmpty()){
answer.append(" ");
continue;
}
if(word.charAt(0) == ' ' && word.length() > 1){
int count = counting(word);
String newW = Character.toUpperCase(word.charAt(count)) + word.substring(count + 1);
for (int i = 0; i < count; i++) {
answer.append(" ");
}
answer.append(newW).append(" ");
}else {
String newWord = Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase();
answer.append(newWord).append(" ");
}
}
return answer.deleteCharAt(answer.length() - 1).toString();
}
public int counting(String word){
int count = 0;
char[] w = word.toCharArray();
for (char c : w) {
if(c == ' '){
count++;
}
}
return count;
}
}