leetcode609
public class Solution {
public IList<IList<string>> FindDuplicate(string[] paths) {
Dictionary<string, List<string>> map = new Dictionary<string, List<string>>();
foreach (string path in paths)
{
string[] tokens = path.Split(' ');
for (int i = ; i < tokens.Length; i++)
{
string file = tokens[i].Substring(, tokens[i].IndexOf('('));
var begin = tokens[i].IndexOf('(') + ;
var end = tokens[i].IndexOf(')') - begin;
string content = tokens[i].Substring(begin, end);
if (!map.ContainsKey(content))
{
map.Add(content, new List<string>());
}
map[content].Add(tokens[] + "/" + file);
}
}
IList<IList<string>> list = new List<IList<string>>();
var list2 = map.Values.Where(e => e.Count > ).ToList();
foreach (var l2 in list2)
{
list.Add(l2);
}
return list;
}
}
https://leetcode.com/problems/find-duplicate-file-in-system/#/solutions
leetcode609的更多相关文章
- [Swift]LeetCode609. 在系统中查找重复文件 | Find Duplicate File in System
Given a list of directory info including directory path, and all the files with contents in this dir ...
随机推荐
- Rope的简单介绍
repo的一些用法和理解 repo简单来讲就是一种调用git的一个脚本文件,用来管软件项目的软件仓库配置文件,描述了软件之间的一些依赖关系. 在Google的android项目下: repo只是goo ...
- L143 Seasonal 'Plague' Hits College Freshman
Sometimes, all the hand sanitizer in the world cannot prevent the inevitable.College freshmen across ...
- 【CSAPP】一、计算机系统漫游
一.位+上下文 文本文件 / 二进制文件: 文本文件是只由ASCII码构成的文件 二.从源代码到可执行文件的顺序 源代码 ——> 可执行文件(机器代码)共有四步: 全过程代码 gcc hello ...
- File I/O的总结
1读写字符文件 BufferedReader br=new BufferedReader(new FileReader("文件路径")); BufferedWriter bw=ne ...
- 关于iframe和div窗口中ajax请求200状态时执行的回调问题
上一篇说了在ajax回调里面处理iframe窗口的刷新问题,这一篇记录一下遇到的一个分别在iframe和div窗口中ajax请求200状态时执行的回调问题. 我们先来看一下ajax请求的写法(这里使用 ...
- [置顶]
Android RadioButton与TextView浪漫约会?
情景一 今天主要实现一个国家与地区切换,就是当我们选中RadioButton时然后将值设置到TextView中,听着这需求应该不难对吧?那么我们就开始约会吧? 看下原型图 准备条件: 首先需要一个ra ...
- 修改maven仓库位置
在eclipse中安装好maven2的插件后: 第一步: 默认会放在~/.m2/repository目录下 (“~”代表用户的目录,比如windows7下一般都是C:\Users\zz\.m2\rep ...
- 前端之JavaScript 01
一JavaScript介绍 js历史 1992年Nombas开发出C-minus-minus(C--)的嵌入式脚本语言(最初绑定在CEnvi软件中).后将其改名ScriptEase.(客户端执行的语言 ...
- freemarker 常见问题
<#setting date_format="yyyy-MM-dd"> ..设置时间格式然后获取从后台获取值${s.createTime?date}这样就能正常显示了 ...
- self = [super init] 最终解释
答: init 中调用super的 init方法来初始化自己所包含有的父类信息 1.内存分配 内存应该在[Class alloc]的时候就已经分配了,大小和类型应该由对应的Clas ...