Блог пользователя Rohancoder

Автор Rohancoder, история, 21 месяц назад, По-английски

Given a string consisting of ()[]{}. Find the length of the longest Balanced Parenthesis in O(N)

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится

»
21 месяц назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

One way to do it is count all the closing and opening parenthesis for each parenthesis and sum up the minimum of opening and closing parenthesis for a given parenthesis.

Edit- Ohk so this case is only valid if the opening comes before the closing one so its not a good solution. It can be done via dp maybe not sure