Arithmetic or Geometric Sequence Detection
Asked at Beaconfire · Coding Questions · Difficulty: Easy · Last asked Jul 15, 2026
Given an integer array `arr`, write a function `ArithGeo(arr)` that returns the string `'Arithmetic'` if the sequence follows an arithmetic pattern, or `'Geometric'` if it follows a geometric pattern. If neither pattern is met, return `-1`. An arithmetic sequence is one where the difference between each number and the previous one is constant. A geometric sequence is one where the ratio between each number and the previous one is constant. Negative numbers may appear, and the array has at least two numbers.
Loading the problem…