목록프로그래머스 연습 (14)
rueki
SELECT YEAR(OS.SALES_DATE) AS YEAR, MONTH(OS.SALES_DATE) AS MONTH, UI.GENDER AS GENDER, COUNT(DISTINCT UI.USER_ID) AS USERS FROM USER_INFO AS UI JOIN ONLINE_SALE AS OS ON (UI.USER_ID = OS.USER_ID) WHERE UI.GENDER IS NOT NULL GROUP BY YEAR, MONTH, GENDER ORDER BY YEAR, MONTH, GENDER ASC user id 를 기준으로 inner join 혹은 left join을 하고 요구하는 컬럼 출력
이번 문제는 순수 구현에 관련된 문제인 것 같은 느낌이다. def solution(n, words): answer = [0, 0] word_arr = [[] for _ in range(n)] for idx, w in enumerate(words): idx_o = idx % n # 첫 단어는 그냥 넣기 if idx == 0: word_arr[idx_o].append(w) else: word_arr[idx_o].append(w) #순서가 0-1-2-0 ~ 이런식으로 반복 # 다시 첫 순서면 이전 순서는 마지막 숫자로 기입 if idx_o == 0: prev = n-1 else: prev = idx_o - 1 #끝말잇기가 안되는 경우 if word_arr[prev][-1][-1] != word_arr[idx_..
2중 for문으로 연속된 숫자 더해서 target 값보다 크면 시작점 1 증가해서 다시 더해서 비교하는 식으로 진행 def solution(n): answer = 0 for i in range(1, n + 1): s = 0 for j in range(i, n+1): s +=j if s == n: answer += 1 break elif s >n: break return answer
- C ++ #include #include using namespace std; int solution(vector land) { int answer = 0; for(int i = 0 ; i < land.size() - 1; i++) { land[i+1][0] += max(land[i][1], max(land[i][2], land[i][3])); land[i+1][1] += max(land[i][0], max(land[i][2], land[i][3])); land[i+1][2] += max(land[i][0], max(land[i][1], land[i][3])); land[i+1][3] += max(land[i][0], max(land[i][1], land[i][2])); } answer = max(l..