Trains the technique from
LeetCode 2235Add Two IntegersThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A stock sheet records every correction to a line as one signed whole number: a positive value adds units to the line, a negative value removes them, and zero leaves the line where it was.
Two corrections have been filed against the same line, first and then
second. Whoever filed them wants to replace both with a single correction that
moves the line to exactly the same place.
Return that single correction.
Example 1
Adding 7 units and then removing 3 leaves the line 4 units above where it started.
Example 2
Both corrections remove units, so the line ends up 65 units below where it started.
Example 3
The second correction undoes the first exactly, so the replacement correction is 0.
Example 4
The first correction leaves the line alone, so only the second one has any effect.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def sum(first: int, second: int) -> int:public int sum(int first, int second)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.