Differences Between Two Objects — LeetCode 2700 Python Solution

MediumLeetCode PremiumJavaScript
Problem
#2700
Reading time
2 min

The problem

Write a function that accepts two deeply nested objects or arrays obj1 and obj2 and returns a new object representing their differences. The function should compare the properties of the two objects and identify any changes.

Example

Input
obj1 = {}
Output
{}
Explanation
There were no modifications made to obj1. New keys "a" and "b" appear in obj2, but keys that are added or removed should be ignored.

Complexity

MeasureComplexity
TimeO(n)
SpaceO(1) to O(n) auxiliary

Related problems

Frequently asked questions

How hard is LeetCode 2700. Differences Between Two Objects?
LeetCode 2700. Differences Between Two Objects is rated Medium on LeetCode.
What topics does LeetCode 2700. Differences Between Two Objects cover?
LeetCode 2700. Differences Between Two Objects is tagged JavaScript on LeetCode.
Is LeetCode 2700. Differences Between Two Objects a premium problem?
Yes. LeetCode 2700. Differences Between Two Objects is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity — invisible to screen sharing.

Get Stealth Interview