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. WCF之MSMQ消息队列

    一.MSMQ简介 MSMQ(微软消息队列)是Windows操作系统中消息应用程序的基础,是用于创建分布式.松散连接的消息通讯应用程序的开发工具. MSMQ与XML Web Services和.Net ...

  2. Mybatis-Generator逆向工程,简单策略

    1.下载generator包 https://github.com/mybatis/generator/releases mybatis-generator-core-1.3.6.zip 官网下载即可 ...

  3. Maven dependencies說明

    一.今天搭建了一个maven项目,在pom.xml文件引入依赖后,发现项目结构中没有Maven Dependencies文件(下图),但是在java Build Path中又可以找到Maven Dep ...

  4. tomcat配置虛擬路徑

    1.server.xml设置 打开Tomcat安装目录,在server.xml中<Host>标签中,增加<Context docBase="硬盘目录" path= ...

  5. BZOJ2155(?) R集合 (卡特兰数)

    Orz Freopen大佬 CODE fac = [0]*1005 def C(n, m): return fac[n] // fac[m] // fac[n-m] n = int(input()) ...

  6. SublimeText 括号插件 Bracket Highlighter高亮设置

    1. ctrl + shift + p,打开命令面板,输入install,在菜单中选择Package Control:Install Package如图 2. 步骤1后弹出的命令输入框中 输入:Bra ...

  7. greenplum(postgresql) 数据字典

    greenplum是基于postgresql开发的分布式数据库,里面大部分的数据字典是一样的.我们在维护gp的时候对gp的数据字典比较熟悉,特此分享给大家.在这里不会详细介绍每个字典的内容,只会介绍常 ...

  8. 代码 | 自适应大邻域搜索系列之(7) - 局部搜索LocalSearch的代码解析

    前言 好了小伙伴们我们又见面了,咳咳没错还是我.不知道你萌接连被这么多篇代码文章刷屏是什么感受,不过,酸爽归酸爽.今天咱们依然讲代码哈~不过今天讲的依然很简单,关于局部搜索LocalSearch的代码 ...

  9. 微信H5的video标签解决方案

    https://github.com/cczw2010/weixin-video 偶尔发现了可以h5化的一种更适合的方式,一个有趣的属性 h5-page 已经更新

  10. fixedFluxPressure边界条件【转载】

    转载自:http://blog.sina.com.cn/s/blog_e256415d0102vikh.html fixedFluxPressure是OpenFOAM较新的一个边界条件,表示边界处压力 ...