Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- class solution{
- public:
- bool judgeCircle( std::string moves )
- {
- if( std::count( moves.begin(), moves.end(), 'L') != std::count( moves.begin(), moves.end(), 'R'))
- {
- return false;
- }else if( std::count( moves.begin(), moves.end(), 'D') != std::count( moves.begin(), moves.end(), 'U')) {
- return false;
- }
- return true;
- }
- };
- int main()
- {
- solution sol;
- bool result;
- std::string input;
- std::cin>>input;
- std::transform( input.begin(), input.end(), input.begin(), [](unsigned char c) { return std::toupper(c); } );
- result = sol.judgeCircle(input);
- if(result == 0)
- {
- std::cout<<"false"<<std::endl;
- }else {
- std::cout<<"true"<<std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment