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 | 446 Views, 35837 Search Bots | 68 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 446 Views, 35837 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 | 446 Views, 35837 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
- Multitasking
- Maximum In A Stack
- CPU Utilization
- Consecutive Ones
- Algorithm Interview: Make the Largest Number
- Compare Version Numbers
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
- Algorithm Interview: Subarray With Target Sum
- Reverse a Linked List
- Most Frequent Subtree Sum
©2006~2024 SteakOverCooked - 0.00761 Seconds(s) - 7105.737 KB/s - 30 Online Memory: 517.83 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 !