Problem Solving
13. Single Number
굥깡
2022. 9. 4. 00:46
728x90
https://leetcode.com/problems/single-number/
Single Number - 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:
def singleNumber(self, nums: list[int]) -> int:
for i in nums:
if nums.count(i) == 1:
return i
1분 만에 풀었으나 런타임이 오래 걸림