LeetCode solutions

3397. Find the Integer Added to Array I

My accepted C++ solution to LeetCode problem 3397, Find the Integer Added to Array I, running in 0ms.

  • Difficulty: Easy
  • C++
  • Runtime 0ms
  • Memory 35MB

Read the problem on LeetCode View on GitHub

C++

Accepted on LeetCode — runtime 0ms, memory 35MB, accepted 2025-12-27.

cpp
class Solution {
    public:
    int addedInteger(vector<int>& nums1, vector<int>& nums2) {
        int sum1 = 0, sum2 = 0;
        for (int n : nums1) sum1 += n;
        for (int n : nums2) sum2 += n;
        return (sum2 - sum1) / (int)nums1.size();
    }
};

Source