题目描述:
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given "25525511135",
return ["255.255.11.135",
"255.255.111.35"]. (Order does not matter)
因为给的子串最多就只能有3*4=12个,所以可以用简单的递归来做而不用担心超时。
#define vs vector<string>
class Solution {
public:
vs restoreIpAddresses(string s)
{
vs ans;
string tmp;
restore(s,0,1,tmp,ans);
return ans;
}
void restore(string& s,in......
阅读全文