93.Restore IP Addresses(M)
617237FavoriteShare
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
Example:
Input: "25525511135"
Output: ["255.255.11.135", "255.255.111.35"]
class Solution {
public:
vector<string> restoreIpAddresses(string s) {
vector<string> result;
string ip;
dfs(s,,,ip,result); //paras:string s,start index of s,step(from0-3),intermediate ip,final result
return result;
}
void dfs(string s,int start,int step,string ip,vector<string>& result){
){
ip.erase(ip.end()-); //remove the last '.' from the last decimal number
result.push_back(ip);
return;
}
-step)*) return;
-step)) return;
;
;i++){
num=num*+(s[i]-');
){
ip+=s[i];
dfs(s,i+,step+,ip+'.',result);
}
) break;
}
}
};
// zjchenRice
93.Restore IP Addresses(M)的更多相关文章
- leetcode 93. Restore IP Addresses(DFS, 模拟)
题目链接 leetcode 93. Restore IP Addresses 题意 给定一段序列,判断可能组成ip数的所有可能集合 思路 可以采用模拟或者DFS的想法,把总的ip数分成四段,每段判断是 ...
- 93. Restore IP Addresses
题目: Given a string containing only digits, restore it by returning all possible valid IP address com ...
- 【LeetCode】93. Restore IP Addresses
Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...
- leetcode 93 Restore IP Addresses ----- java
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
- 【一天一道LeetCode】#93. Restore IP Addresses
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- 93. Restore IP Addresses产生所有可能的ip地址
[抄题]: Given a string containing only digits, restore it by returning all possible valid IP address c ...
- LeetCode OJ 93. Restore IP Addresses
题目 Given a string containing only digits, restore it by returning all possible valid IP address comb ...
- 93. Restore IP Addresses(dfs)
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
- [LeetCode] 93. Restore IP Addresses 复原IP地址
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
随机推荐
- Dynamics 365中显示格式为URL的字段极少部分URL值录入了不显示怎么回事?
微软动态CRM专家罗勇 ,回复318或者20190315可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 对于如下类型的字段, ...
- 2.5 Cesium视域分析的实现
Cesium 视域分析 祝愿周末没事,技术继续分享交流,群685834990
- 【设计模式】简单工厂模式 Simple Factory Pattern
简单工厂模式Simple Factory Pattern[Simple Factory Pattern]是设计模式里最简单的一个模式,又叫静态工厂模式[Static Factory Pattern], ...
- WordCount项目基本功能
一.项目源代码地址 本人Gitee项目地址:https://gitee.com/yuliu10/WordCount 二.PSP表格 psp阶段 预估耗时 (分钟) 实际耗时 (分钟) 计划 30 10 ...
- linux 搭建squid代理服务器
linux 搭建squid代理服务器 实验环境: 一台linux搭建Web服务器,充当内网web服务器(同时充当内网客户端) 202.100.10.100 一台linux系统充当网关服务器,两个网卡, ...
- java编译过程中出现了Exception in thread “main" java.lang.UnsupportedClassVersionError
原因:这个问题确实是由较高版本的JDK编译的java class文件试图在较低版本的JVM上运行产生的错误. 以下是报错截图: 1.解决措施就是保证jvm(java命令)和jdk(javac命令)版本 ...
- Python基础之if判断,while循环,循环嵌套
if判断 判断的定义 如果条件满足,就做一件事:条件不满足,就做另一件事: 判断语句又被称为分支语句,有判断,才有分支: if判断语句基本语法 if语句格式: if 判断的条件: 条件成立后做的事 . ...
- 教你在浏览器里做出EXCEL的效果
在浏览器里做出EXCEL的效果,复制.粘贴.设置公式.双击编辑等效果,如果自己开发的话,比较麻烦,建议使用成熟的插件.这里介绍使用智表ZCELL插件,实现用户快捷操作. 首先下载插件,引入到页面中,一 ...
- vue源码分析—认识 Flow
认识 Flow Flow 是 facebook 出品的 JavaScript 静态类型检查⼯具.Vue.js 的源码利⽤了 Flow 做了静态类型检查, 所以了解 Flow 有助于我们阅读源码 Flo ...
- ubuntu tree 查看目录结构
首先需要安装tree这个软件 sudo apt install tree tree -L target_dir/ 2代表列举的目录结构深度