知之者 不如好之者, 好之者 不如樂之者

기계처럼 살지 말고, 즐기는 인간이 되자

Code/LeetCode

[LeetCode] 136. Single number (Easy/Python)

코방코 2022. 9. 26. 17:21
728x90
 

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

Above is the link to the problem.

 

Problem

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

You must implement a solution with a linear runtime complexity and use only constant extra space.

 

Example :

Input: nums = [4,1,2,1,2]
Output: 4

 

I solved this problem by the below code.

 

 

This code get the top 71.42% of the time efficiency and use 16.5 MB of memory.

728x90
반응형