April Fool On The Hill Of Love

By now you can see I’m all about our ancestors. Today was my brother’s earthly birthday. Fond memories of Christopher today. This is an article I wrote in 2006 about him. Twenty years and I still…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Checking for balanced parentheses with JS

Earlier this week I was playing around with a toy problem which involves returning a boolean denoting whether or not a given string contains balanced parentheses or not. Basically, for a correct implementation the following strings should cause the function to return true

but inputs like this

should cause the function to evaluate to false.

I really liked this solution because it a) is not recursive b) handles all edge cases) and c) uses a stack.

I’m not sure when I will apply this knowledge of stacks next, but I’d like to think that learning about random things will help me to write more expressive code and solve problems in creative ways down the line. And while this problem (checking for balanced parentheses) might seem like it has no real world application, it is actually really important. As anyone whose ever programmed in JavaScript or another parentheses-heavy language knows, it can sometimes be difficult to ensure you have the correct numbers of parentheses in your code. This is why a lot of modern text editors like vsc have handy built-in tools for highlighting the opening and closing parenthesis of a pair. In a sense, solving this problem is one of the many features you’d want to implement if you were to ever take on an ambitious personal project like writing your own text editor. In a sense, it is possible that accumulating a lot of experience with small problems like this is part of a broader journey to becoming a more well-rounded programmer.

Add a comment

Related posts:

My savior. My little bear.

I picked a date because I saw it might not get better. By the end of it, id make it where no one cared about me anymore. Sitting on the tailgate, I began to feel light rain and I was watching the…

Sally Mann.

Having met Sally Mann in 2016 was an exciting experience. She is a woman with an acute intelligence and sensitive power that paralyzes anyone. In the defense of her role as a mother, she said: “The…

Anumol Thomas

At the young age of 10, Anumol Thomas was inspired by her aunt who was practicing as a nurse in the United States. Following in her aunt’s footsteps, Dr. Thomas began her journey into nursing. In…