You are not logged in. Please login at www.codechef.com to post your questions!

×

ZCO15001 breakup why is tis code giving a partially correct answer

This question is a part of the ZCO practice contest (question link) . I do not know where I'm going wrong ,please help.

#include<bits/stdc++.h>
using namespace std;
long N;
vector<long> numb;
int pal=0;
int palcheck(int k)
{
vector<long> rever;
int temp;
vector<long> rever2;
while(k<N) {
rever.push_back(numb[k]);
rever2=rever;
reverse(rever2.begin(),rever2.end());
if(rever==rever2){
temp=k+1;}
k++;
}
pal=pal+1;
return temp;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cin >> N;
for (int i = 0; i < N; i++)
{int temp;
cin>>temp;
numb.push_back(temp);
}
int i=0;
while(i<N){
vector<long> rever;
vector<long> rever2;
int k=i;
while(k<N)
{
rever.push_back(numb[k]);
rever2=rever;
reverse(rever2.begin(),rever2.end());
if(rever==rever2){
i=k+1;}
k++;
}
pal=pal+1;
}
cout<<pal;
return 0;
}

asked 23 Nov '18, 21:31

karan26122001's gravatar image

2★karan26122001
11
accept rate: 0%

edited 23 Nov '18, 21:38

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,901
×421
×3

question asked: 23 Nov '18, 21:31

question was seen: 52 times

last updated: 23 Nov '18, 21:38