preface

I am a big LOL fan, I try my best to express knowledge in canyon language, to help myself and the zero basic white understand, I believe that even king of Glory players can understand the general.

Well, if you don’t know anything, this should help you improve your IQ.

This article will be written in JavaScript and Python in LeetCode brush algorithm problems, you can watch my route together to start the game.

Details and suggestions for this wave on the line:

  • Systematic learning of knowledge is not easy to forget

Equipment do not buy randomly, shoes, myth equipment, core equipment, defense equipment, etc., gather together six gods.

  • If you can’t beat him, press “B” and get back to town. Follow your legs

Faced with a new topic without any clue, directly give up to see the solution, and then write down, repeatedly review, until the solution becomes their own knowledge. This is the most efficient way to learn.

  • Accept yourself as a novice

When he is a bronze son on the line, duan slowly added, one day on the king

This article is:

  • Stacks and queues and linked list sections

Topic directory

  • 20. Valid brackets
  • 946. Validate stack sequence
  • 921. Minimum additions to make parentheses valid
  • 901. Stock price span
  • 739. Daily temperature
  • 907. Sum of minimum values of subarrays
  • Reverse the substring between each pair of parentheses
  • 1249. Remove invalid parentheses

The collection! Prepare for mass battle!

20. Valid brackets

20. Valid brackets

My problem:

class Solution: def isValid(self, s: str) -> bool: if len(s)%2 == 1 : return False pairs = { "}":"{", ")":"(", "]":"[", } stack = list() for ch in s: if ch in pairs: # If pairs[-1]!=pairs[ch]: return False stack.pop() else: # if pairs.append() return not stackCopy the code

Summary:

  • Len (stack) == 0

  • View the top of the stack: stack[-1]

LOL language:

The characteristics of the stack are advanced and then out. At this point we assume that there are three couples, Lacos and Ez, Xia and Lo, and Sena and Lucian. Equal to our parentheses,{},[],(),

They walked into the small dragon pit, now the small dragon pit in accordance with the characteristics of the stack, a person in the first, the last to come out.

Now, we create a smart dragonpit Pairs that knows who is in a relationship with who. Given ez you get the Lacus result.

Now there is a group, they are ez Charuxenrax Losena {[()]}

We have to decide if they have the right combination

Scan each of them, if it is a male (right parentheses), let him see if the last into the small dragon pit is his wife, (he can only see who is the last into the small dragon pit) if it is a female, let him directly into the small dragon pit.

Not his wife, direct false, is his wife, let his wife out of the small dragon pit, go out to fill a soldier together.

Finally, xiaolong Pit no one, on behalf of everyone has a wife, everyone no problem. Xiaolong Pit someone, on behalf of a problem!