Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
V F
Question on abs(targetDiff) logic

V F

Dec 2, 2024

if (Math.abs(targetDiff) < Math.abs(smallestDifference) || (Math.abs(targetDiff) == Math.abs(smallestDifference)

Can't this be written as Math.abs(targetDiff) <= Math.abs(smallestDifference)?

0

0

Comments
Comments

On this page

Problem Statement

Try it yourself