Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
