leetcode394专题

L75-25(Leetcode394字符串解码)

代码: 两个栈 一个存数字 一个存字符串 class Solution {public String decodeString(String s) {Deque<String> stack2 = new LinkedList<>();Deque<Integer> stack1 = new LinkedList<>();int n = s.length();StringBuffer res =

LeetCode394 Decode String java solution

题目链接: https://leetcode.com/problems/decode-string/ 点击打开链接 题目要求: Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside

Leetcode394. 字符串解码

Every day a Leetcode 题目来源:394. 字符串解码 解法1:栈 本题中可能出现括号嵌套的情况,比如 2[a2[bc]],这种情况下我们可以先转化成 2[abcbc],在转化成 abcbcabcbc。我们可以把字母、数字和括号看成是独立的 TOKEN,并用栈来维护这些 TOKEN。 具体的做法是,初始化一个栈 stk = stack<string>,遍历字符串 s,设

LeetCode394. Decode String字符串解码

394. Decode String 题意: Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k t