I am trying to find out the the no of permutations possible for a string that are palindrome.The only way I could think of is finding out the possible permutations and then checking if each one of them is palindrome or not. Is there any better way?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 166 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 160 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
I am trying to find out the the no of permutations possible for a string that are palindrome.The only way I could think of is finding out the possible permutations and then checking if each one of them is palindrome or not. Is there any better way?
Hello I am trying to solve the question :http://www.spoj.com/problems/PT07Z/ in SPOJ. I have used bfs to find the leaf node and then used bfs again to find the maximum path.I am trying this approach and I don't know what is causing the error. Here is a link to my solution http://ideone.com/QSJzDf.
I was solving maximum quad area in SPOJ. Here is the link http://www.spoj.com/problems/QUADAREA/. It is a pretty simple one based on formula. However when I used the formula in C++ it showed WA. But the same formula and same logic showed acc when i used scanf and printf. Is there something I am missing? Here are the links to the codes: with cin: http://ideone.com/kSPbfU without cin: http://ideone.com/uF0yiK
I am trying to solve the problem RENT on SPOJ. Here is the link http://www.spoj.com/problems/RENT/.I have done it using dynamic programming and binary search. I cant figure out what is wrong with my code.Here is a link to my code : http://ideone.com/UgnBRN . Please Help.
I am trying to solve SPOJ street parade. But i dont know what is wrong in the following code:
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstdio>
using namespace std;
int main(){
int n,ne,last;
cin>>n;
while(n!=0){
int ar[n];
last=0;
stack <int> s;
for(int i=0;i<n;i++)
cin>>ar[i];
for(int i=0;i<n;i++){
if(s.top()==(last+1)){
s.pop();
last++;
}
else if(ar[i]==(last+1))
last++;
else if(!s.empty() && s.top()<ar[i]){
cout<<"no"<<endl;
continue;
}
else
s.push(ar[i]);
}
cout<<"yes"<<endl;
cin>>n;
}
return 0;
}
Name |
---|