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 | 427 Views, 35292 Search Bots | 68 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 427 Views, 35292 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 | 427 Views, 35292 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
- Maximum In A Stack
- Number of Ways to Climb Stairs
- Staying on a Chess Board
- Invert a Binary Tree
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Algorithm Interview Question: Symmetric k-ary Tree
- YES!!
- Find Pythagorean Triplets
- Algorithm Interview: Convert Roman Numerals to Decimal
- Fix Brackets
©2006~2024 SteakOverCooked - 0.00666 Seconds(s) - 2789.006 KB/s - 34 Online Memory: 493.37 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 !