Skip to content

Commit

Permalink
Palindrome Function
Browse files Browse the repository at this point in the history
  • Loading branch information
ahany42 committed Jun 1, 2024
1 parent ebd2884 commit d14b14b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Ds-Stacks/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ stack<int> DecimalToBinary(int number) {
}
return binaryStack;
}
bool Palindrome(string str) {
stack <char> s;
for (int i = 0; i < str.length(); i++) {
s.push(str[i]);
}
for (int i = 0; i < str.length(); i++) {
if (str[i] != s.top())
return false;
s.pop();
}
else return true;
}
int main()
{

Expand Down

0 comments on commit d14b14b

Please sign in to comment.