ssjgz
83
1 Like
rocww
84
what should be the output for this testcase?
2?
https://www.codechef.com/viewsolution/33184548
This is my code. Where am I going wrong?
Please help.
ssjgz
85
The answer for the test input:
1
<><
should be 2
, yes.
Your solution fails on the following testcase:
1
<<><
rocww
86
I think I passed these two testcases. Still failing.
https://www.codechef.com/viewsolution/33186008
ssjgz
87
1
>
(your code has an out-of-bounds access on this test input).
1 Like
While solving the problem, I had a doubt, will be grateful if answered. What should be the output for the input, “<><<<>>>”?
troyun
91
Can anyone help me with this code, returning WA :
My code
Your code doesn’t works on this test case:
<>><
Your output- 0
Correct output- 2
1 Like
Input
4
<<>>>><>
<><<<<>
<>>>
<<><>>
output
4
2
2
6
check these
it is giving me wa ,can u plss help out me here
here is code:
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
string str;
cin>>str;
class Node{
public:
char value;
int indexvalue;
};
std::stack f;
int start=0;
int end=0;
int k=-1;
for(int i=0;i<str.size();i++){
char s = str[i];
if(i == 0){
if(s == '>'){
break;
}
}
if(s=='<'){
Node n;
n.value=s;
n.indexvalue=i;
f.push(n);
}
else{
if(!f.empty()){
Node tempnode=f.top();
f.pop();
int tempstart=tempnode.indexvalue;
int tempend=i;
int tempk=tempend-tempstart;
if(tempk>k){
k=tempk;
start=tempstart;
end=tempend;
}
}
}
}
cout<<k+1<<endl;
}
}
ssjgz
97
It fails on the sample input.
2 Likes
https://www.codechef.com/viewsolution/43631671
still gives me WA although I tested almost every input
please tell me why i am getting wa ;(
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t–)
{
string s;
cin>>s;
long n=s.size();
stack st;
long count=0,max=0;
for(long i=0;i<n;i++)
{
if(s[i]==’<’)
st.push(s[i]);
else if(st.empty())
st.push(s[i]);
else
{
if(s[i]==’>’ and st.top()==’<’)
{
st.pop();
count=count+2;
}
else if(s[i]==’>’ and st.top()!=’<’)
count=0;
else
{
st.push(s[i]);
}
}
if(count>max) max =count;
}
// long st_size=st.size();
// long prefix=n-st_size;
// cout<<prefix<<"\n";
cout<<max<<"\n";
}
// your code goes here
return 0;
}
please help me out to debug it
ssjgz
101
Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! 