- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ code to check array can be formed from Equal Not-Equal sequence or not
Suppose we have a string S of length . Consider there are n numbers and they are arranged in a circle. We do not know the values of these numbers but if S[i] = 'E' it indicates ith and (i+1)th numbers are same, but if that is 'N' then they are different. From S we have to check whether we can recreate the sequence or not.
So, if the input is like S = "ENNEENE", then the output will be True, because we can assign values like [15,15,4,20,20,20,15].
Steps
To solve this, we will follow these steps −
if S has single 'N', then: return false return true
Example
Let us see the following implementation to get better understanding −
#include<bits/stdc++.h> using namespace std; bool solve(string S){ if (count(S.begin(), S.end(), 'N') == 1) return false; return true; } int main(){ string S = "ENNEENE"; cout << solve(S) << endl; }
Input
"ENNEENE"
Output
1
- Related Articles
- C++ Program to check given candies can be split with equal weights or not
- C++ code to check all bulbs can be turned on or not
- Program to check subarrays can be rearranged from arithmetic sequence or not in Python
- Program to check two strings can be equal by swapping characters or not in Python
- C++ code to check grasshopper can reach target or not
- Check if two StringDictionary objects are equal or not in C#
- C++ code to check phone number can be formed from numeric string
- Golang Program to Check If Two Arrays are Equal or Not
- Golang Program to Check Whether Two Matrices are Equal or Not
- Swift Program to Check Whether Two Matrices Are Equal or Not
- Swift Program to Check if Two Arrays Are Equal or Not
- Program to check whether one string swap can make strings equal or not using Python
- Check if two strings are equal or not in Arduino
- Check whether two schedules are view equal or not(DBMS)
- C++ code to check string is diverse or not

Advertisements