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 | 429 Views, 35374 Search Bots | 68 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 429 Views, 35374 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 | 429 Views, 35374 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
- Generate All IP Addresses
- Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
- Consecutive Ones
- Daily Interview Question: Edit Distance
- Algorithm Interview: No Adjacent Repeating Characters
- [Daily Problem] Course Prerequisites
- Daily Interview Problem: Sort Colors
- Daily Interview Puzzle: Ways to Traverse a Grid
- Daily Interview Problem: Trapping Rainwater
©2006~2024 SteakOverCooked - 0.00705 Seconds(s) - 2833.957 KB/s - 46 Online Memory: 494.02 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 !