当前位置: 首页 > news >正文

C语言 | Leetcode C语言题解之第385题迷你语法分析器

题目:

题解:

struct NestedInteger* helper(const char * s, int * index){if (s[*index] == '[') {(*index)++;struct NestedInteger * ni = NestedIntegerInit();while (s[*index] != ']') {NestedIntegerAdd(ni, helper(s, index));if (s[*index] == ',') {(*index)++;}}(*index)++;return ni;} else {bool negative = false;if (s[*index] == '-') {negative = true;(*index)++;}int num = 0;while (s[*index] && isdigit(s[*index])) {num = num * 10 + s[*index] - '0';(*index)++;}if (negative) {num *= -1;}struct NestedInteger * ni = NestedIntegerInit();NestedIntegerSetInteger(ni, num);return ni;}
}struct NestedInteger* deserialize(char * s){int index = 0;return helper(s, &index);
}

http://www.mrgr.cn/news/16009.html

相关文章:

  • Memcached stats sizes 命令
  • C++入门基础知识43——【关于C++循环】
  • Spring Boot集成Spring Cloud Scheduler进行任务调度
  • AI学习指南深度学习篇-长短时记忆网络python实践
  • Visual Studio Code离线汉化
  • Flask蓝图的作用
  • 深入理解Python中的`super()`函数:如何调用父类的方法
  • C++ 中的信号量:一种高效的线程同步机制
  • 读软件开发安全之道:概念、设计与实施14低级编码缺陷
  • 使用Redis如何实现集群会话同步?
  • 【STM32】通用定时器TIM(时钟源选择与更新中断)
  • 代码随想录算法训练营第三十九天| LeetCode62.不同路径、LeetCode63.不同路径II、LeetCode343. 整数拆分
  • Java后端数据一致性保障:分布式事务解决方案
  • laravel8快速开发简单博客系统(二)
  • Android 13.0 framework新增控制以太网开关功能实现
  • 一个最基本的多线程3D渲染器方案
  • Canvas 在 微信小程序-uni-APP 和 H5 中的使用差异
  • C语言 | Leetcode C语言题解之第386题字典序排数
  • 保姆级Maven安装、配置、版本查询教程(包含配置本地仓库、阿里云私服、环境变量)
  • Tengine框架之配置表的Luban转换与加载