Is The List Palindrome?

`#include <bits/stdc++.h>
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
list<int> lst;
int val;
while (cin >> val && val != -1)
{
lst.p…


This content originally appeared on DEV Community and was authored by Mujahida Joynab

`#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    list<int> lst;
    int val;
    while (cin >> val && val != -1)
    {
        lst.push_back(val);
    }
    int f = 0;
    for (int i = lst.front(), j = lst.back(); i < j; i++, j--)
    {
        if (i != j)
        {
            f = 1;
            break;
        }
    }
    if (f)
    {
        cout << "NO\n";
    }
    else
        cout << "YES\n";
}`


This content originally appeared on DEV Community and was authored by Mujahida Joynab


Print Share Comment Cite Upload Translate Updates
APA

Mujahida Joynab | Sciencx (2025-02-01T10:36:36+00:00) Is The List Palindrome?. Retrieved from https://www.scien.cx/2025/02/01/is-the-list-palindrome/

MLA
" » Is The List Palindrome?." Mujahida Joynab | Sciencx - Saturday February 1, 2025, https://www.scien.cx/2025/02/01/is-the-list-palindrome/
HARVARD
Mujahida Joynab | Sciencx Saturday February 1, 2025 » Is The List Palindrome?., viewed ,<https://www.scien.cx/2025/02/01/is-the-list-palindrome/>
VANCOUVER
Mujahida Joynab | Sciencx - » Is The List Palindrome?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/01/is-the-list-palindrome/
CHICAGO
" » Is The List Palindrome?." Mujahida Joynab | Sciencx - Accessed . https://www.scien.cx/2025/02/01/is-the-list-palindrome/
IEEE
" » Is The List Palindrome?." Mujahida Joynab | Sciencx [Online]. Available: https://www.scien.cx/2025/02/01/is-the-list-palindrome/. [Accessed: ]
rf:citation
» Is The List Palindrome? | Mujahida Joynab | Sciencx | https://www.scien.cx/2025/02/01/is-the-list-palindrome/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.