Cody

Problem 2589. Find Elements in Range

Created by Guillaume in Community

Based on a question on MATLAB Answers.

Find all the elements of a vector whose difference, regardless of position is less or equal than a given range.

Example

 A = [1 4 7 10 2 8];
 range = 1;
 inrange = [1 0 1 0 1 1]; % since diff(1, 2) <= 1 and diff(7, 8) <= 1

Solution Stats

64.15% Correct | 35.85% Incorrect
Last solution submitted on Apr 20, 2019

Problem Comments

Solution Comments