Weekly Challenge: Longest Expression
dev.to·19h·
Discuss: DEV
Flag this post

Weekly Challenge 346

Each week Mohammad S. Anwar sends out The Weekly Challenge, a chance for all of us to come up with solutions to two weekly tasks. My solutions are written in Python first, and then converted to Perl. It’s a great way for us all to practice some coding.

Challenge, My solutions

Task 1: Longest Parenthesis

Task

You are given a string containing only ( and ).

Write a script to find the length of the longest valid parenthesis.

My solution

I start by writing a function called is_balanced, which takes a string as input. It counts the number of open and clos…

Similar Posts

Loading similar posts...