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. cvte2018春招前端开发实习面试分享

    编程题问题描述: 返回整数数组中出现次数第n多的数字(返回值可能有多个) 最近在找实习,面试二面最后出了一道这样的编程题,当时有思路但语法有错误,而且很紧张,最后没有运行出来,导致凉凉,回来重新思考了 ...

  2. js实现发送验证码倒计时效果

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. vs编译自定义编译任务记录,msbuild

    https://www.cnblogs.com/whitewolf/archive/2011/07/27/2119005.html http://www.cnblogs.com/hjf1223/arc ...

  4. 对象(面向对象、创建对象方式、Json)

    一.面向对象 面向过程:凡事亲力亲为,每件事的具体过程都要知道,注重过程 面向对象:根据需求寻找对象,所有的事都用对象来做,注重结果 面向对象特性:封装.继承.多态(抽象性) js是一门基于对象的语言 ...

  5. SSD检测几个小细节

    目录 一. 抛砖引玉的Faster-RCNN 1.1 候选框的作用 1.2 下采样问题 二. SSD细节理解 2.1 六个LOSS 2.2 Anchor生成细节 2.3 Encode&& ...

  6. Web前端-JavaScript基础教程下

    Web前端-JavaScript基础教程下 <script>有6个属性: async对外部脚本有效,可以用来异步操作,下载东西,不妨碍其他操作. charset为src属性指定字符集. d ...

  7. Springboot @ConditionalOnProperty注解

    最近看了一段代码其中用到了@ConditionalOnProperty注解,直接没有了解过这个注解,今天看到了顺便了解一下 具体代码如下 @Configuration public class Web ...

  8. 6.Python3字符串和格式化

    一.字符串 1.字符串表示方法 2.字符串的序号 3.字符串的使用 4.字符串切片 5.字符串的特殊字符 6.字符串操作符 案例:输入对应的数字显示对应的星期 '''weekStr = "星 ...

  9. 关于大JSON 的问题的解决方式

    ASP.NET MVC JSON 大数据异常提示JSON 字符串超出限制的异常问题 今天客户突然过来找我说在后台添加了一篇超长的文章后,所有后台的文章都显示不出来了.后台的前端显示是用easyui的, ...

  10. kafka 45个题目介绍

    >1.Kafka面试问答 Apache Kafka的受欢迎程度很高,Kafka拥有充足的就业机会和职业前景.此外,在这个时代拥有kafka知识是一条快速增长的道路.所以,在这篇文章中,我们收集了 ...