To the Top
File:  root - text - article - 2020 - 01 - find-the-single-element-in-an-array-of-duplicates.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 144 Views, 27953 Search Bots | 68 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Apple:

Given an array of integers, arr, where all numbers occur twice except one number which occurs once, find the number. Your solution should ideally be O(n) time and use constant extra space.
Example:
Input: arr = [7, 3, 5, 5, 4, 3, 4, 8, 8]
Output: 7


class Solution(object):
def findSingle(self, nums):
# Fill this in.

nums = [1, 1, 3, 4, 4, 5, 6, 5, 6]
print(Solution().findSingle(nums))
# 3
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 144 Views, 27953 Search Bots | 68 Words Subscribe to Feed Burner

Related Articles

  1. Maximum In A Stack
  2. Daily Interview Problem: Contiguous Subarray with Maximum Sum
  3. Daily Interview Problem: Trapping Rainwater
  4. Daily Interview Problem: 3 Sum
  5. [Daily Problem] Remove Consecutive Nodes that Sum to 0
  6. Daily Interview Problem: Spiral Traversal of Grid
  7. Daily Interview Problem: Group Words that are Anagrams
  8. Daily Interview Problem: Maximum Profit From Stocks
  9. Daily Interview Question: Find Cycles in a Graph
  10. Two-Sum

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />