Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Check Whether Three Numbers Form an Arithmetic Progression

Basic Acceptance 73.03% Points 10.00

You are given three numbers. Your task is to determine whether they form an arithmetic progression (AP), meaning the difference between consecutive terms is constant.

Print Yes if the numbers form an arithmetic progression; otherwise, print No.

Examples
Example 1

Input: a = 2, b = 4, c = 6
Output: Yes
Explanation: The common difference is 2 throughout.

Example 2

Input: a = 1, b = 3, c = 6
Output: No
Explanation: The differences 2 and 3 are not equal.

Example 3

Input: a = 5, b = 5, c = 5
Output: Yes
Explanation: A constant sequence has a common difference of 0.

Constraints
  • -10? = a, b, c = 10?
Companies
Apple Samsung Walmart DE Shaw
Topics
Data Structures Basics
Solution.cs C#JavaPythonC++Javascript

Unlock the code editor

Sign in to write, run, and submit your solution against the full test suite.

  • Run code against sample & hidden test cases
  • Save submissions and track your streak
  • Compare with editorial & community solutions