Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Javascript code Simba considers a sequence of numbers special only if there are no such pair of adjacent numbers in the sequence such that the
Javascript code
Simba considers a sequence of numbers special only if there are no such pair of adjacent numbers in the sequence such that the pair consists of both odd or both even numbers.
Simba received a sequence of numbers A from his friend as a birthday present. Can you tell if the sequence is nice to him or not?
Input Format
The first line shall contain a single integer N denoting the number of values in the array.
Then, N lines follow, where each line shall contain a single integer, denoting the value of the ith element of the array.
Output Format
Print "YES" if the sequence is special or NO if its not in a single line.
Constraints
N
Array values
Examples
Input:
Output:
YES
Explanation:
The first value is odd followed by an even number and the process goes on which makes this a special sequence.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started