[Leetcode] 811.Subdomain Visit Count

Java实现 LeetCode 811 子域名访问计数 (暴力) 811. 子域名访问计数 一个网站域名,如”discuss.leetcode.com”,包含了多个子域名。作为顶级域名,常用的有”com”,下一级则有”leetcode.com”,最低的一级为”discuss.leetcode.com”。当我们访问域名”discuss.leetcode.com”时,也同时访问了其父域名”leetcode.com”以及顶级域名 “com”。 给定一个带访问次数和域名的组合,要求分别计算每个域名被访问的次数。其格式为访问次数+空格+地址,例如:“9001 discuss.leetcode.com”。 接下来会给出一组访问次数和域名组合的列表cpdomains 。要 立即下载

Description:

A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit the parent domains "leetcode.com" and "com" implicitly.

Now, call a "count-paired domain" to be a count (representing the number of visits this domain received), followed by a space, followed by the address. An example of a count-paired domain might be "9001 discuss.leetcode.com".

We are given a list cpdomains of count-paired domains. We would like a list of count-paired domains, (in the same format as the input, and in any order), that explicitly counts the number of visits to each subdomain.


Example:

Example 1:
Input: 
["9001 discuss.leetcode.com"]
Output: 
["9001 discuss.leetcode.com", "9001 leetcode.com", "9001 com"]
Explanation: 
We only have one website domain: "discuss.leetcode.com". As discussed above, the subdomain "leetcode.com" and "com" will also be visited. So they will all be visited 9001 times.
Example 2:
Input: 
["900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"]
Output: 
["901 mail.com","50 yahoo.com","900 google.mail.com","5 wiki.org","5 org","1 intel.mail.com","951 com"]
Explanation: 
We will visit "google.mail.com" 900 times, "yahoo.com" 50 times, "intel.mail.com" once and "wiki.org" 5 times. For the subdomains, we will visit "mail.com" 900 + 1 = 901 times, "com" 900 + 50 + 1 = 951 times, and "org" 5 times.

class Solution {

    public List<String> subdomainVisits(String[] cpdomains) {
        Map<String,Integer> a = new HashMap<String,Integer>();
        for (String object : cpdomains) {
            String[] base = object.split("\\s+");
            String[] dom = base[1].split("\\.");
            int acct = Integer.valueOf(base[0]);
            String temp= "";
            for (int i = dom.length - 1; i >=0; i--) {
                temp = dom[i] + (i == dom.length - 1?"" : ".") + temp;//这一块的语法还不是很懂
                a.put(temp,a.getOrDefault(temp,0) + acct);
            }
        }
        List<String> result = new ArrayList<String>();
        for (String key : a.keySet()) {
            result.add(a.get(key) + " " + key);
        }
        return result;
    }
}
Ubuntu运行vmware时报错Vmware Unable to install all modules!Use shipped Linux kernel AIO access library解决。 Ubuntu运行vmware时报错Vmware Unable to install all modules! vmware --version 提示下面内容: [AppLoader] Use shipped Linux kernel AIO access library. An up-to-date "libaio" or "libaio1" package from your system is preferred. VMware Workstation 16.1.2 build-17966106 阅读详情

相关推荐

本体研究综述(转)

(这篇文章是从http://imarine.blog.163.com/中转载过来的,个人觉得对本体的介绍比较全面!)本体综述本体作为一种能在语义和知识层次上描述领域概念的建模工具,其目标是捕获相关领域的知识,确定该领域内共同认可的词汇,通过概念之间的关系来描述概念的语义,提供对该领域知识的共同理解。语义Web(the Semantic Web)是在本体理论基础之上对现有Web所进行的扩展[

zhenshideni611的专栏 1839

[leetcode-811-Subdomain Visit Count]

A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode....

weixin_34363171的博客 173

基于Android13的系统启动流程分析(三)之FirstStageMain阶段

init进程是Android系统中用户空间的第一个进程,作为第一个进程,它被赋予了很多极其重要的工作职责,比如创建zygote(孵化器)和属性服务等。init进程是由多个源文件共同组成的,这些文件位于源码目录system/core/init1. Bootloader 引导当按下设备电源键时,最先运行的就是 bootloader(固化在ROM的程序),bootloader 的主要作用就是硬件设备(如 CPU、flash、内存)的初始化并加载到RAM,通过建立内存空间映射,为装载 Linux 内核做好准备,。

q1210249579的博客 5496

811-Subdomain Visit Count

Description: A website domain like “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at the next level, we have “leetcode.com”, and at the lowest level, “discuss...

fighting! 875

以太网物理层协议整理(2)-万兆以太网

在万兆以太网标准化过程中,IEEE和10GEA(万兆以太网联盟)是两个最重要的组织。 万兆以太网标准和规范都比较繁多,在标准方面,首先有2002年的IEEE 802.3ae,后来也不断有新的万兆以太网规范推出,如2006年的IEEE 802.3an标准(10GBase-T)就推出了基于双绞铜线的万兆以太网规范,同样的IEEE 802.3aq标准推出了基于光纤的10GBase-LRM;2007年的

NowOrNever 3万+

SPL06气压温度传感器SPI驱动与补偿算法详解

气压传感器与温度传感器是嵌入式环境感知系统的核心组件,其测量精度高度依赖于MEMS芯片的校准参数与非线性补偿机制。SPL06作为集成式高精度数字传感器,采用24位Σ-Δ ADC与片内补偿引擎,需结合唯一出厂校准系数(即‘芯片指纹’)进行多阶数学修正,才能将原始ADC值转化为符合计量要求的帕斯卡(Pa)与摄氏度(℃)物理量。该过程涵盖SPI通信协议解析、寄存器时序控制、大端数据拼接、二进制补码处理及浮点/定点混合运算等典型嵌入式工程实践。广泛应用于无人机高度计、智能穿戴海拔监测与IoT气象终端中。

weixin_34640289的博客 143

811. Subdomain Visit Count

A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.com"...

dxx707099957的博客 438

若依框架二次开发——若依 Vue3 版本前端样式优化指南

若依框架二次开发——若依 Vue3 版本前端样式优化指南

bjzhang75的博客 1695

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

【LeetCode】811. Subdomain Visit Count 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/subdomain-visit-count/description/ 题目描述: A website domain like “discuss.leetcode.com” co...

负雪明烛 3582

STM32(HAL库)驱动st7789LCD屏幕(7引脚240*240)

屏幕厂家提供的都是标准库,网上找了找没看到好用的HAL库屏幕驱动,因此本文对HAL库驱动TFT屏幕进行详细讲解。

weixin_44597885的博客 6068

【推荐100个unity插件之10】Unity Cinemachine最全的最详细的虚拟相机介绍,详细案例讲解,快速上手

相信很多同学都用过Unity的Cinemachine插件,使用它可以很方便地实现一些摄像机效果,比如摄像机追踪、推拉镜头、分镜等效果。Cinemachine的知识特别的多又很常用,本来是想做一期来讲一下的,结果搜索发现已经有人做过了,而且内容挺全的,但是内容可能比较啰嗦,还有部分没有补充,所以我就先转载下来,后续有时间再优化修改补充,觉得内容不错的,很欢迎大家去支持原作者。

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 2万+

Leetcode PHP题解--D36 811. Subdomain Visit Count

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33849215的博客 121

即插即用系列(代码实践) | CVPR 2025 WPFormer:小波与原型增强Transformer——表面缺陷检测SOTA,专治弱缺陷与杂乱背景

摘要:本文提出了一种基于小波变换和原型增强的Transformer模型(WPFormer),用于像素级表面缺陷检测。该模型针对工业场景中微弱缺陷难以识别和杂乱背景干扰严重的问题,创新性地将小波变换引入Transformer的注意力机制,通过频域信息分离噪声与边缘特征,同时利用原型向量引导查询,实现了更精准的缺陷定位。核心模块包括小波增强交叉注意力(WCA)和原型引导交叉注意力(PCA),适用于工业缺陷检测、伪装目标检测和医学图像分割等任务。代码已开源,支持即插即用集成到现有框架中。

分享顶会顶刊论文即插即用模块 302

LeetCode //C - 811. Subdomain Visit Count

Algorithm Summary: The solution counts subdomain visits by parsing each input string into a visit count and domain, then iteratively processes all possible subdomains (e.g., "discuss.leetcode.com" → "leetcode.com" → "com"). A

Made in Code 1555

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

[leetcode] 811. Subdomain Visit Count

题目:A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.c...

jing16337305的博客 423

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

[leetcode]811. Subdomain Visit Count

[leetcode]811. Subdomain Visit Count Analysis old friends~—— [嘻嘻~] A website domain like “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at the next l...

weixin_32135877的博客 125

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Leetcode——811. Subdomain Visit Count

题目原址 https://leetcode.com/problems/subdomain-visit-count/description/ 题目描述 A website domain like “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at the nex...

想当厨子的程序媛 321

Leetcode 811. Subdomain Visit Count

class Solution(object): def subdomainVisits(self, cpdomains): """ :type cpdomains: List[str] :rtype: List[str] """ count = {} for cpdom in ...

weixin_30834019的博客 96

[Leetcode] 811. Subdomain Visit Count 解题报告

题目: A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leet

魔豆(Magicbean)的博客 391

[leetcode] 811. Subdomain Visit Count @ python

原题 A website domain like “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at the next level, we have “leetcode.com”, and at the lowest level, “discuss.leetcode.c...

闲庭信步 209

[LeetCode] 811. Subdomain Visit Count

A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode...

dfojc86648的专栏 119

【leetcode】811. Subdomain Visit Count

class Solution { public List<String> subdomainVisits(String[] cpdomains) { List<String> result = new ArrayList(); Map<String,Integer> domainMap = new Hash...

Art1st_D的博客 239

【python3】leetcode 811. Subdomain Visit Count(easy)

811. Subdomain Visit Count(easy) A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the l...

momottyy的专栏 255

leetcode 811. Subdomain Visit Count python

class Solution(object): def subdomainVisits(self, cpdomains): """ :type cpdomains: List[str] :rtype: List[str] """ ant = collections.Counter() for d...

mario_mmh的博客 386

【leetcode 811】Subdomain Visit Count

##Map#####[Subdomain Visit Count]#######811-问题描述####A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.c...

drunkpragrammer的博客 807
上一篇: [Leetcode] 476. Number Complement
下一篇: [Leetcode] 463. Island Perimeter
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值