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 | 428 Views, 35369 Search Bots | 68 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 428 Views, 35369 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 | 428 Views, 35369 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
- Patterns for breaking down questions you haven
- [Daily Problem] Remove Consecutive Nodes that Sum to 0
- ImageMagick Vulnerabilities - CVE-2016–3714
- Reverse a Directed Graph
- Spectrum Master
- Daily Interview Problem: Queue Using Two Stacks
- [Daily Problem] Remove k-th Last Element From Linked List
- Daily Interview Problem: Merge List Of Number Into Ranges
- A trick for getting good at coding interviews FASTER
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
©2006~2024 SteakOverCooked - 0.01418 Seconds(s) - 1453.895 KB/s - 35 Online Memory: 494.73 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="index, 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 !