728x90
데일리루틴 SQL
MySQL 우유와 요거트가 담긴 장바구니 정답입니다.
SELECT
CART_ID
FROM
CART_PRODUCTS
WHERE
NAME = 'Milk'
AND CART_ID IN (
SELECT
CART_ID
FROM
CART_PRODUCTS
WHERE NAME = 'Yogurt'
)
ORDER BY
CART_ID;
데일리루틴 알고리즘
Java 문자열 나누기 정답입니다.
class Solution {
public int solution(String s) {
int answer = 0;
int countX = 0;
int countOther = 0;
char x = 0;
for (int i = 0; i < s.length(); i++) {
if(countX == 0 && countOther == 0) {
x = s.charAt(i);
countX++;
} else {
if (s.charAt(i) == x) {
countX++;
} else {
countOther++;
}
}
if (countX == countOther) {
answer++;
countX = 0;
countOther = 0;
}
}
if (countX != 0 || countOther != 0) {
answer ++;
}
return answer;
}
}
728x90
반응형
LIST
'Sparta > 데일리루틴' 카테고리의 다른 글
TIL(Today I Learned)_데일리루틴_24.12.11.Wed (0) | 2024.12.11 |
---|---|
TIL(Today I Learned)_데일리루틴_24.12.09.Mon (0) | 2024.12.09 |
TIL(Today I Learned)_데일리루틴_24.12.08.Sun (0) | 2024.12.08 |
TIL(Today I Learned)_데일리루틴_24.12.07.Sat (0) | 2024.12.07 |
TIL(Today I Learned)_데일리루틴_24.12.06.Fri (0) | 2024.12.06 |