Answered step by step
Verified Expert Solution
Link Copied!

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
1<= N <=1,00,000
1<= Array values <=1,000,000,000
Examples
Input:
4
1
2
3
4
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

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

How flying airoplane?

Answered: 1 week ago