Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class ArrayOneTwoThree { public static boolean arrayOneTwoThree(int[] nums) { for (int i = 0; i < nums.length - 2; i++) { if (nums[i] ==

public class ArrayOneTwoThree { public static boolean arrayOneTwoThree(int[] nums) { for (int i = 0; i < nums.length - 2; i++) { if (nums[i] == 1 && nums[i + 1] == 2 && nums[i + 2] == 3) { return true; } } return false; } public static void main(String[] args) { int[] nums1 = {1, 1, 2, 3, 1}; System.out.println("arrayOneTwoThree([1, 1, 2, 3, 1]) " + arrayOneTwoThree(nums1)); int[] nums2 = {1, 1, 2, 4, 1}; System.out.println("arrayOneTwoThree([1, 1, 2, 4, 1]) " + arrayOneTwoThree(nums2)); int[] nums3 = {1, 1, 2, 1, 2, 3}; System.out.println("arrayOneTwoThree([1, 1, 2, 1, 2, 3]) " + arrayOneTwoThree(nums3)); } } Add one more number in code int[] nums4 {1, 2, 3, 1, 1, 2}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago