Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@SherlockHolmes3 | 447 |

@codeantik | 441 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

@neverevergiveup | 381 |

@amrutakashikar2 | 355 |

@mahlawatep | 353 |

@murarry3625 | 352 |

Complete Leaderboard |

Given three integers '**A**' denoting the first term of an arithmetic sequence , '**C**' denoting the common difference of an arithmetic sequence and an integer '**B**'. you need to tell whether 'B' exists in the arithmetic sequence or not.

**Example 1:**

**Input:** A = 1, B = 3, C = 2
**Output:** 1
**Explaination:** 3 is the second term of the
sequence starting with 1 and having a common
difference 2.

**Example 2:**

**Input:** A = 1, B = 2, C = 3
**Output:** 0
**Explaination:** 2 is not present in the sequence.

**Your Task:**

You do not need to read input or print anything. Your task is to complete the function **inSequence()** which takes A, B and C and returns 1 if B is present in the sequence. Otherwise, returns 0.

**Expected Time Complexity:** O(1)

**Expected Auxiliary Space:** O(1)

**Constraints:**

-10^{9} ≤ A, B, C ≤ 10^{9}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Arithmetic Number

...