| 
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                     
                                        
                                     
                                    
                                        
                                        - 博士后
 
                                        
                                        - 2699998
 
                                        - 3587
 
                                        - 11
 
                                        - 2173 朵
 
                                        - 7386 个
 
                                        - 1021 个
 
                                        - 91120
 
                                        - 2014-08-23
 
                                     
                                    
                                    
                                    
                                 | 
                                
                                    
                                        
                                            
                                                
                                                1#
                                                
                                            
                                        
                                        
                                            
                                                
                                                
                                                t
                                                T
                                             
                                            
                                            
                                            
                                                
                                                发表于 2022-11-06 14:13
                                            
                                                                                        
                                            | 
                                            
                                            
                                            |只看楼主
                                            
                                         
                                     
                                    
                                    
                
                
                
                
                    
                    
                    
                   
                    
                        
                        
                        题目描述 请你设计一个可以解释字符串 command 的 Goal 解析器 。command 由 "G"、"()" 和/或 "(al)" 按某种顺序组成。Goal 解析器会将 "G" 解释为字符串 "G"、"()" 解释为字符串 "o" ,"(al)" 解释为字符串 "al" 。然后,按原顺序将经解释得到的字符串连接成一个字符串。 给你字符串 command ,返回 Goal 解析器 对 command 的解释结果。 提示: 1 <= command.length <= 100 command 由 "G"、"()" 和/或 "(al)" 按某种顺序组成
  【示例】1: 输入:command = "G()(al)" 输出:"Goal" 解释:Goal 解析器解释命令的步骤如下所示: G -> G () -> o (al) -> al 最后连接得到的结果是 "Goal"
  【示例】2: 输入:command = "G()()()()(al)" 输出: "Gooooal"
  【示例】3: 输入:command = "(al)G(al)()()G" 输出:"alGalooG"
 
  题目难度:简单 题目来源:goal-parser-interpretation | leetcode 题目交流:  584781753
 
  |  
 - Import "SmAssert.dll"
  
  
- Function 设计Goal解析器(命令)
  
-     // 您的代码写在这里
  
- End Function
  
  
  
- SmAssert.That 设计Goal解析器("G()(al)"), "=", "Goal"
  
- SmAssert.That 设计Goal解析器("G()()()()(al)"), "=", "Gooooal"
  
- SmAssert.That 设计Goal解析器("(al)G(al)()()G"), "=", "alGalooG"
  
  复制代码 参考题解- Import "SmAssert.dll"
  
  
- Function 设计Goal解析器(命令)
  
-     
  
-     '【作者】:神梦无痕
  
-     '【QQ】:1042207232
  
-     '【Q群】:584781753
  
-     
  
-     Dim R    /* Long */
  
-     Dim L    /* Long */
  
-     Dim i    /* Long */
  
-     Dim c    /* String */
  
-     Dim Ret /* String */
  
-     
  
-     Ret = ""
  
-     L = 0
  
-     R = 0
  
-     For i = 1 To Len(命令)
  
-         c = Mid(命令, i, 1)
  
-         If c = "G" Then 
  
-             Ret = Ret & "G"
  
-         ElseIf c = "(" Then 
  
-             L = i
  
-         ElseIf c = ")" Then
  
-             R = i
  
-             If R - L - 1 = 0 Then 
  
-                 Ret = Ret & "o"
  
-             Else 
  
-                 Ret = Ret & Mid(命令, L + 1, R - L - 1)
  
-             End If
  
-         End If
  
-     Next
  
-     设计Goal解析器 = Ret
  
- End Function
  
  
- SmAssert.That 设计Goal解析器("G()(al)"), "=", "Goal"
  
- SmAssert.That 设计Goal解析器("G()()()()(al)"), "=", "Gooooal"
  
- SmAssert.That 设计Goal解析器("(al)G(al)()()G"), "=", "alGalooG"
  
  复制代码 插件下载【插件】神梦断言插件 SmAssert.dll,帮助开发者发现业务逻辑错误  
                        
                     
                    
                    
                    
                    
                    
                    
                    
                    
                        
                        
                     
                     |