말하는대로

  • 홈
  • 태그
  • 방명록

Combinations 1

[Leetcode] 1512. Number of Good Pairs

Problem 이번 문제는 배열 안에 같은 값을가지는 ( i,j ) 쌍이 몇가지 있는지 찾는 문제이다 나의 풀이 class Solution: def numIdenticalPairs(self, nums: List[int]) -> int: res = 0 import itertools a_list = itertools.combinations(nums,2) for i in a_list: if i[0] == i[1]: res += 1 return res 이전에 itertools에 있는 combinations를 사용한 기억을 되살려 저걸 활용해서 문제를 풀었다 itertools.combinations(iterable , r) combinations는 iterable 한 객체를 r 의 길이를 가진 조합들을 뽑아내준다..

Python/algorithm 2022.12.25
이전
1
다음
더보기
반응형
프로필사진

말하는대로

순간을 후회로 남지않게

  • 분류 전체보기 (78)
    • Python (53)
      • Django (3)
      • algorithm (38)
      • FastAPI (0)
      • core (2)
    • AI (1)
    • Data (3)
    • CS (7)
      • Network (1)
      • 운영체제 (1)
    • Infra (2)
      • GCP (1)
      • CICD (0)
    • etc (3)
    • App (2)
      • Android (1)
      • iOS (1)
      • etc (0)
    • gekco (1)
    • LostArk (0)
    • DesignPattern (1)
    • Project (1)
      • QnA_With_Your_Sentiment (1)
    • Devops (2)

Tag

DB, reptile, leetcode, list, class, Til, SQL, CS, 게코, Gecko, 크레스티드게코, Python, 항해, django, 알고리즘, Algorithm, 파이썬, OOP, 백준, 파충류,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2025/10   »
일 월 화 수 목 금 토
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 31

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바