Inf1 OP : Lab Sheet Week 5 Q2 - Has 271
Overview

Write a program Has271 containing a static method has271() with the following signature:

public static boolean has271(int[] nums)

Given an array of type int[], return true if the array contains a 2, 7, 1 pattern; that is, a value, followed by the value plus 5, followed by the value minus 1.

Here are some examples of evaluating the method on representative input values:

has271({1, 2, 7, 1}) -> true
has271({1, 2, 8, 1}) -> false
has271({2, 7, 1}) -> true
has271({4, 9, 3}) -> true

An automated test has been created for this exercise: Has271Test.java.