Single Number II [LeetCode][June Challenge]

Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.

Note:

Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Example 1:

Input: [2,2,3,2]
Output: 3

Example 2:

Input: [0,1,0,1,0,1,99]
Output: 99

Solution:

--

--

--

I am Indian by birth, Punjabi by destiny. Humanity is my religion. Love to eat, travel, read books and my million dreams keep me alive.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

MongoDB all operations

Dead Lock

6. 互鎖控制回路

What went down at Meesho’s Hack.Mee (2.0) edition Hackathon

MOST UPDATE NEWS ABOUT BLIND BOX TICKET CAMPAIGN FOR 1025 LAST TICKETS IN NFT BOX PURCHASE…

Essential Tools for Site Reliability Engineers

Hardening Docker and Kubernetes with seccomp

Useful Hacks In Google Docs: Tips You Never Knew You Needed Till Now.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Navneet Ojha

Navneet Ojha

I am Indian by birth, Punjabi by destiny. Humanity is my religion. Love to eat, travel, read books and my million dreams keep me alive.

More from Medium

Leetcode — 1891. Cutting Ribbons

3–Longest Substring Without Repeating Characters

[LeetCode] (Easy) 27. Remove Element

Minimum Hop Cost [Dynamic Programming]