-
1678. Goal Parser Interpretation javaLeetCode_Study_Plan/Programming Skills 2022. 9. 21. 15:00
https://leetcode.com/problems/goal-parser-interpretation/?envType=study-plan&id=programming-skills-i
class Solution { public String interpret(String command) { StringBuilder sb = new StringBuilder(); for (int p = 0, q = 1; p < command.length(); p++, q++) { char c = command.charAt(p); if (c == 'G') sb.append('G'); if (c == '(') { if (command.charAt(q) == ')') { sb.append("o"); p++; q++; } else { sb.append("al"); p += 2; q += 2; } } } return sb.toString(); } }
'LeetCode_Study_Plan > Programming Skills' 카테고리의 다른 글
[Programming Skills I] 이틀 뒤, 중간 점검 (2) 2022.09.21 389. Find the Difference java (0) 2022.09.21 1768. Merge Strings Alternately java (1) 2022.09.21 566. Reshape the Matrix java (1) 2022.09.21 1572. Matrix Diagonal Sum java (0) 2022.09.21