-
1679. Max Number of K-Sum PairsAlgorithm/python tip 2021. 3. 1. 18:13
leetcode.com/problems/max-number-of-k-sum-pairs/ Max Number of K-Sum Pairs - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com from collections import Counter class Solution(object): def maxOperations(self, nums, k): dic = Counter(nums) ans = 0 for n in nums: if k - n in dic: if n ==..
-
137. Single Number IIAlgorithm/python tip 2021. 3. 1. 17:56
leetcode.com/problems/single-number-ii/ Single Number II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution(object): def singleNumber(self, nums): dic = {k: 0 for k in nums} for k in nums: dic[k] += 1 print(dic) for k, v in dic.items(): if v == 1: return k
-
1726. Tuple with Same ProductAlgorithm/python tip 2021. 3. 1. 13:02
leetcode.com/problems/tuple-with-same-product/ Tuple with Same Product - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com
-
1052. Grumpy Bookstore OwnerAlgorithm/python tip 2021. 2. 28. 02:59
leetcode.com/problems/grumpy-bookstore-owner/ Grumpy Bookstore Owner - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com - Time Limit Exceeded ''' https://leetcode.com/problems/grumpy-bookstore-owner/ 점주는 가계를 customers.length 동안 연다. 매분 customers[i] 만큼의 손님이 가계를 들어온다. 특정시간동안 점주는 성격이 더럽..
-
1481. Least Number of Unique Integers after K RemovalsAlgorithm/python tip 2021. 2. 28. 02:17
list to map convert security-nanglam.tistory.com/427 [python] List to Dict (리스트를 딕셔너리로 변환) 총 정리!! 검색어 : List to Dict List 에서 Dict으로 변환하는 방법에는 여러가지 방법이 있습니다...! string_list = ['A','B','C'] 위와 같은 리스트가 있을때, 딕셔너리로 변환시키는 여러가지 방법들 ..! 1. Dictionary.. security-nanglam.tistory.com dictinary sort by value stackoverflow.com/questions/72899/how-do-i-sort-a-list-of-dictionaries-by-a-value-of-the-dictionary ..
-
565. Array NestingAlgorithm/python tip 2021. 2. 27. 04:31
leetcode.com/problems/array-nesting/ - Worng answer ''' 길이 N인 리스트 A [0, 1, 2, .. N-1] 다음을 만족하는 가장 긴 길이의 set S를 리턴 S[i] = {A[i], A[A[i]], A[A[A[i]]]} ''' class Solution(object): def arrayNesting(self, nums): """ :type nums: List[int] :rtype: int """ ans = [] mySet = set() index = 0 while nums[index] not in mySet: ans.append(nums[index]) mySet.add(nums[index]) index = nums[index] # prepare next in..