Q1.
Single NumberUnsolved
Asked in:
SH
TO
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
Problem Description
Given an array of integers A, every element appears twice except for one. Find that
integer that occurs once.
NOTE: Your algorithm should have a linear runtime complexity. Could you implement it
without using extra memory?
Problem Constraints
2 <= |A| <= 2000000
0 <= A[i] <= INTMAX
Input Format
The first and only argument of input contains an integer array A.
Output Format
Return a single integer denoting the single element.
Example Input
Input 1:
A = [1, 2, 2, 3, 1]
Input 2:
A = [1, 2, 2]
Example Output
Output 1:
Output 2:
Example Explanation
Explanation 1:
3 occurs once.
Explanation 2:
1 occurs once.
See Expected Output
Q2. Number of 1 BitsUnsolved
Asked in:
AD
YA
QU
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
Problem Description
Write a function that takes an integer and returns the number of 1 bits it has.
Problem Constraints
1 <= A <= 109
Input Format
First and only argument contains integer A
Output Format
Return an integer as the answer
Example Input
Input1:
11
Example Output
Output1:
3
Example Explanation
Explaination1:
11 is represented as 1011 in binary.
See Expected Output