PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: pols_agyi_pols
Tester: kingmessi
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
You’re given X, Y, and K.
Decide whether |X-Y| \leq K.
EXPLANATION:
Do exactly what the statement asks: check whether |X-Y| \leq K or not.
You can do this by either using the abs function (available in most languages), or checking if both X-Y and Y-X are \leq K.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (Python)
x, y, k = map(int, input().split())
print('Yes' if abs(x-y) <= k else 'No')