Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
blanaced parenthes
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here var word = "[3{242]}]"; var arrChr = word.ToCharArray(); List<char> pushList = new List<char>(); char[] parenClose = {')', ']', '}'}; char[] parenOpen = {'(','[','{'}; for(int i=0; i<arrChr.Length; i++) { if(parenClose.Contains(arrChr[i])){ var lastParens=pushList[pushList.Count-1]; if((lastParens == '{' && arrChr[i] == '}') || (lastParens == '(' && arrChr[i] == ')') || (lastParens == '[' && arrChr[i] == ']')) { pushList.RemoveAt(pushList.Count-1); }else{ Console.WriteLine("Error not valid !"); return; } } else if(parenOpen.Contains(arrChr[i])) pushList.Add(arrChr[i]); } Console.WriteLine("Success valid"); } } }
run
|
edit
|
history
|
help
0
EpsilonComparer
Test
DASX
Date Comparison
Variables
bubble sort
TempConverter
Masking Credit Card Number
Sort example
Plt-D v.0.9 WOA