File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * @lc app=leetcode.cn id=1678 lang=cpp
3+ *
4+ * [1678] 设计 Goal 解析器
5+ */
6+ #include < stack>
7+ #include < sstream>
8+ using namespace std ;
9+ // @lc code=start
10+ class Solution {
11+ public:
12+ string interpret (string command) {
13+ stack<char > sc;
14+ stringstream s;
15+ char c;
16+ for (size_t i = 0 ; i < command.size (); i++) {
17+ if (command[i] == ' G' ) {
18+ s << " G" ;
19+ } else if (command[i] == ' )' ) {
20+ int j = 0 ;
21+ while ((c = sc.top ()) != ' (' ) {
22+ sc.pop ();
23+ j++;
24+ }
25+ sc.pop ();
26+ if (j == 0 ) {
27+ s << " o" ;
28+ } else {
29+ s << " al" ;
30+ }
31+ } else {
32+ sc.push (command[i]);
33+ }
34+ }
35+ return s.str ();
36+ }
37+ };
38+ // @lc code=end
39+
Original file line number Diff line number Diff line change 1+ /*
2+ * @lc app=leetcode.cn id=791 lang=cpp
3+ *
4+ * [791] 自定义字符串排序
5+ */
6+
7+ // @lc code=start
8+ class Solution {
9+ public:
10+ string customSortString (string order, string s) {
11+
12+ }
13+ };
14+ // @lc code=end
15+
You can’t perform that action at this time.
0 commit comments