As reported: Sony Group (Japan), new-grad Software Engineer (Embedded Linux), online assessment, October 2025: 30 multiple-choice questions and one easy coding problem, in C++ or Python.
You are on the Moon and can carry stones back to Earth with a total weight of at most M. Earth already has N stones whose weights are given in arr. You may pick stones of any positive integer weight, with these rules:
- all the stones you pick have distinct weights;
- none of them has a weight that is already present on Earth;
- their total weight is at most
M.
Return the maximum number of stones you can carry.
Example 1
M = 10, N = 3, arr = [1, 3, 5]
Output: 2
Weights 1, 3, 5 are taken. Pick 2 and 4 (total 6); adding 6 would make 12 > 10.
Example 2
M = 14, N = 4, arr = [4, 6, 7, 9]
Output: 4
Pick 1, 2, 3 and 5 (total 11); the next allowed weight, 8, would make 19 > 14.
Constraints: 1 <= M <= 10^9, 0 <= N <= 10^5, 1 <= arr[i] <= 10^9 (weights in arr may repeat).
Code runner format: two JSON values, one per line: M and arr (N is arr's length). Implement maxStones(M, earth) returning an integer.