220v
젝무의 개발새발
220v
전체 방문자
오늘
어제
  • 분류 전체보기 (255)
    • AI (35)
      • ML, DL 학습 (30)
      • 논문 리뷰 (4)
      • 실습 및 프로젝트 (1)
    • Algorithm (145)
      • LeetCode (13)
      • 프로그래머스 (35)
      • 백준 (96)
      • 알고리즘, 문법 정리 (1)
    • Mobile, Application (17)
      • Flutter (10)
      • iOS, MacOS (7)
    • BackEnd (7)
      • Flask (1)
      • Node.js (5)
      • Spring, JSP..etc (1)
    • Web - FrontEnd (18)
      • JavaScript, JQuery, HTML, C.. (12)
      • React (6)
    • DataBase (1)
      • MySQL (1)
      • Firebase Firestore (0)
      • Supabase (0)
    • Git (1)
    • 기타 툴 및 오류 해결 (3)
    • 강의 (5)
      • Database (3)
      • 암호학 (2)
      • 알고리즘 (0)
    • 후기와 회고 (2)
    • 블로그 꾸미기 (1)
    • 일상과 이것저것 (20)
      • 맛집 (12)
      • 세상사는일 (4)
      • 도서리뷰 (1)
      • 이런저런 생각들 (잡글) (3)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • Lis
  • disjoint set
  • Minimum Spanning Tree
  • 구현
  • Mathematics
  • two pointer
  • bitmasking
  • BFS
  • top-down
  • dfs
  • REACT
  • topological sort
  • simulation
  • 티스토리챌린지
  • 위상 정렬
  • dp
  • Prefix Sum
  • IMPLEMENT
  • Greedy
  • Priority Queue
  • 프로그래머스
  • Backtracking
  • brute-Force
  • binary search
  • 오블완
  • 백준
  • implementation
  • 다익스트라
  • Dynamic Programming
  • union-find

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
220v

젝무의 개발새발

Algorithm/프로그래머스

[프로그래머스] 개인정보 수집 유효기간 - 파이썬

2023. 5. 2. 15:06

2023 KAKAO BLIND RECRUITMENT - 150370. 개인정보 수집 유효기간

[Lv. 1]

 

https://school.programmers.co.kr/learn/courses/30/lessons/150370

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

풀이

딱히 설명할 부분은 없는 Lv. 1 문제.

String Slicing과,

유효기간은 개인정보를 보관할 수 있는 달 수를 나타내는 정수이며, 1 이상 100 이하입니다.

라는 설명에 주의하며, month -= 12, year += 1 을 만족할 때까지 반복해줘야 함에만 신경써주면 될 것.

def solution(today, terms, privacies):
    answer = []
    termList = {}
    for t in terms:
        termList[t.split()[0]] = int(t.split()[1])

    privList = []
    for p in privacies:
        privList.append(p.split())

    t_year = int(today[:4])
    t_month = int(today[5:7])
    t_day = int(today[8:10])

    for index, p in enumerate(privList):
        year = int(p[0][:4])
        month = int(p[0][5:7])
        day = int(p[0][8:10])
        c = p[1]

        # term에 따른 month 추가
        m = termList[c]

        month += m
        while month >= 13:
            month -= 12
            year += 1

        # 비교
        if t_year > year:
            answer.append(index+1)
            continue
        elif t_year == year:
            if t_month > month:
                answer.append(index+1)
                continue
            elif t_month == month:
                if t_day >= day:
                    answer.append(index+1)
                else:
                    continue
            else:
                continue
        else:
            continue

    return answer

 

    'Algorithm/프로그래머스' 카테고리의 다른 글
    • [프로그래머스] 표 병합 - 파이썬
    • [프로그래머스] 이모티콘 할인행사 - 파이썬
    • [프로그래머스] 미로 탈출 명령어 - 파이썬
    • [프로그래머스] 표현 가능한 이진트리 - 파이썬
    220v
    220v
    DGU CSE 20 / Apple Developer Academy @ POSTECH 2nd Jr.Learner.

    티스토리툴바