【LeetCode記錄帖】【2】Valid Parentheses

題目鏈接https://leetcode-cn.com/problems/valid-parentheses/code 解法:leetcode 利用壓棧的方法,將棧的頭部和相對於字符串的後一個字符進行比較,若匹配就頭部出棧,不匹配就入棧,最終若是棧爲空即達到有效串的要求。特判一下空串。字符串 class Solution { public: bool isValid(string s) {
相關文章
相關標籤/搜索