[LeetCode][Python3] 287. Find the Duplicate Number
2019. 1. 25. 00:06 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/find-the-duplicate-number/
My Solution :
class Solution:
def findDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
slow = fast = nums[0]
while True:
slow = nums[slow]
fast = nums[nums[fast]]
if slow == fast:
slow = nums[0]
while slow != fast:
slow = nums[slow]
fast = nums[fast]
return slow
Comment :
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 103. Binary Tree Zigzag Level Order Traversal (0) | 2019.02.07 |
---|---|
[LeetCode][Python3] 279. Perfect Squares (0) | 2019.01.31 |
[LeetCode][Python3] 162. Find Peak Element (0) | 2019.01.25 |
[LeetCode][Python3] 328. Odd Even Linked List (0) | 2019.01.25 |
[LeetCode][Python3] 75. Sort Colors (0) | 2019.01.24 |
[LeetCode][Python3] 102. Binary Tree Level Order Traversal (0) | 2019.01.22 |
[LeetCode][Python3] 230. Kth Smallest Element in a BST (0) | 2019.01.15 |
[LeetCode][Python3] 454. 4Sum II (1) | 2019.01.13 |
최근에 달린 댓글 최근에 달린 댓글