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 | 431 Views, 35397 Search Bots | 68 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 431 Views, 35397 Search Bots | 68 Words
| 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
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 431 Views, 35397 Search Bots | 68 Words 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
Related Articles
- Find the non-duplicate number
- Two Tricks of Delphi
- Algorithm Interview Question: Find the Single Element in an Array of Duplicates
- A trick for getting good at coding interviews FASTER
- First and Last Indices of an Element in a Sorted Array
- Daily Interview Problem: Word Ordering in a Different Alphabetical Order
- Algorithm Interview Question: Max and Min with Limited Comparisons
- Algorithm Interview: Longest Consecutive Sequence
- Daily Interview Problem: First Missing Positive Integer
- Daily Interview Problem: Find the k-th Largest Element in a List
©2006~2024 SteakOverCooked - 0.01407 Seconds(s) - 1440.072 KB/s - 25 Online Memory: 493.41 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !