Created
February 2, 2017 19:48
-
-
Save Belouccio/652e9aa7fd44a6ade8bafa9f334be085 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function myFunc(str){ | |
| var shablon="a(){}[]"; | |
| var stek=[]; | |
| for (var i=0; i<str.length; i++){ | |
| var x=str[i]; | |
| var y=shablon.indexOf(x); | |
| if (y>0){ | |
| if(y%2==0){ | |
| if(!stek.length){ | |
| return console.log("не правильно"); | |
| } | |
| var z=stek.pop(); | |
| if(z!=shablon[y-1]){ | |
| return console.log("не правильно"); | |
| } | |
| } else { | |
| stek.push(x); | |
| } | |
| } | |
| } | |
| return (stek.length)? console.log("не правильно") : console.log("правильно"); | |
| } | |
| myFunc("{{{}}}()[[][]]"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment