본문 바로가기

쏘ing

검색하기
쏘ing
프로필사진 한민민

  • 분류 전체보기 (42)
    • SmartThings (4)
    • 졸업작품 (2)
    • KISTI 인턴 (7)
    • 알고리즘 (25)
      • CLASS 1 (4)
      • CLASS 2 (0)
      • CLASS 3 (21)
    • LINUX (2)
    • Spring (0)
    • Python (2)
    • CI CD (0)
    • 책 (0)
    • 조잘조잘💕 (0)
Guestbook
Today
Total
«   2025/09   »
일 월 화 수 목 금 토
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Recent Posts
Recent Comments
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록Python (2)

쏘ing

집합(set)의 remove(), discard() 차이

S = set() S.add(10) # 오류 S.remove(5) # 오류 X S.discard(5) remove() : 실제 존재하는 element를 지우기 위해 사용 시간 복잡도 : O(n) discard() : 집합에 존재하지 않음을 보장하기 위해 사용 시간 복잡도 : O(1) => 집합 사용할 때는 만약 값이 없을 경우 remove() 사용해서 오류 나는 것보다 discard() 써서 값이 없는 경우 무시하고 시간 복잡도도 줄이는 게 훠어어어어얼씬 낫다👍

Python 2022. 2. 9. 11:40
파이썬 입력

입력 - input() - 정수 : int(input()) 공백 제거 - input().split() - 정수 : int(input().split()) 여러 항목(공백 구분) - A, B = map(str, input().split()) - 정수 : A, B = map(int, input().split()) 입력 시간 줄이기 import sys A, B = map(int, sys.stdin.readline().rstrip().split()) 공백 구분 문자열 리스트로 받기 - word = list(map(str, input().split()) - 정수 : num = list(map(int, input().split())

Python 2022. 2. 9. 11:30
Prev 1 Next

Blog is powered by kakao / Designed by Tistory

티스토리툴바