problem

811. Subdomain Visit Count

solution:

class Solution {
public:
vector<string> subdomainVisits(vector<string>& cpdomains) {
vector<string> res;
unordered_map<string, int> subdomain;
int spaceIdx = ;
for(auto cpdomain:cpdomains)
{
spaceIdx = cpdomain.find(" ");//errrrr...
int cnt = stoi(cpdomain.substr(, spaceIdx));
string tmp = cpdomain.substr(spaceIdx+);
for(int i=; i<tmp.size(); ++i)
{
if(tmp[i]=='.') subdomain[tmp.substr(i+)] += cnt;//errr.
}
subdomain[tmp] += cnt;//err..
}
for(auto sub:subdomain)
{
res.push_back(to_string(sub.second) + " " + sub.first);//errr...
}
return res;
}
};

参考

1. Leetcode_easy_811. Subdomain Visit Count;

2. Grandyang;

【Leetcode_easy】811. Subdomain Visit Count的更多相关文章

  1. 【LeetCode】811. Subdomain Visit Count 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典统计次数 日期 题目地址:https://lee ...

  2. 811. Subdomain Visit Count - LeetCode

    Question 811. Subdomain Visit Count Example 1: Input: ["9001 discuss.leetcode.com"] Output ...

  3. LeetCode 811 Subdomain Visit Count 解题报告

    题目要求 A website domain like "discuss.leetcode.com" consists of various subdomains. At the t ...

  4. [LeetCode&Python] Problem 811. Subdomain Visit Count

    A website domain like "discuss.leetcode.com" consists of various subdomains. At the top le ...

  5. LeetCode 811. Subdomain Visit Count (子域名访问计数)

    题目标签:HashMap 题目给了我们一组域名,让我们把每一个域名,包括它的子域名,计数. 遍历每一个域名,取得它的计数,然后把它的所有子域名和它自己,存入hashmap,域名作为key,计数作为va ...

  6. 811. Subdomain Visit Count (5月23日)

    解答 class Solution { public: vector<string> subdomainVisits(vector<string>& cpdomains ...

  7. 811. Subdomain Visit Count

    这题主要难在构建关联容器,方法很多,但是核心都是把原字符串一截一截减下来处理,先把前面用空格隔开的次数转化为整数,然后处理后面的多层子域. 方法一,查找标志字符,用标志字符把字符串分成几段 stati ...

  8. LeetCode算法题-Subdomain Visit Count(Java实现)

    这是悦乐书的第320次更新,第341篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第189题(顺位题号是811).像"discuss.leetcode.com& ...

  9. 【mysql】mysql统计查询count的效率优化问题

    mysql统计查询count的效率优化问题 涉及到一个问题 就是 mysql的二级索引的问题,聚簇索引和非聚簇索引 引申地址:https://www.cnblogs.com/sxdcgaq8080/p ...

随机推荐

  1. Jquery 操作DOM元素

    一.文本输入框: text <input type=”text” value=”99.com” size=12 id=”input1” /> 1.获取文本值: $("#input ...

  2. CSS display详解

    1.解释一下display的几个常用的属性值,inline , block, inline-block inline(行内元素): 使元素变成行内元素,拥有行内元素的特性,即可以与其他行内元素共享一行 ...

  3. ubuntu下卸载旧Mysql并安装新Mysql(升级)

    由于从apt-get下安装的Mysql不是最新版的,所以,需要升级.先卸载,再安装. 1.卸载 先看mysql是否在运行: netstat -tap | grep mysql 然后 sudo apt- ...

  4. Restful架构API编码规范

    Restful API 目前比较成熟的一套互联网应用程序的API设计理论 一.协议 API与用户的通信协议,总是使用HTTPs协议. 二.域名 应该尽量将API部署在专用域名之下. https://a ...

  5. html中的table导出Excel (亲测有用(●'◡'●))

    演示地址: http://www.jq22.com/yanshi3312 具体代码: <!DOCTYPE html> <html lang="zh-CN"> ...

  6. [GraphQL] Query Lists of Multiple Types using a Union in GraphQL

    Unions are used when we want a GraphQL field or list to handle multiple types of data. With a Union ...

  7. 三十四.MySQL主从同步 、主从同步模式

    mysql51:192.168.4.51 主 mysql52:192.168.4.52 从 mysql50:192.168.4.50 客户机   1.MySQL一主一从   1.1 51,52 安装m ...

  8. msyql的子查询,或者叫嵌套查询

    INNER和OUTER可以省略

  9. P5431 【模板】乘法逆元2

    洛谷题目链接 刚开始做乘法逆元还是有点懵逼的~ 以下式子都在模\(p\)意义下进行 我们把式子改一下,变成:\[\sum\limits_{i=1}^nk^i\times a_i^{-1}\] 我们先算 ...

  10. [转]C++ 模板 静态成员 定义(实例化)

    提出问题: 如果有这样一个模板: template <typename T> class Test{ public: static std::string info; }; 对于以下若干种 ...