File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public List<List<String>> findDuplicate(String[] paths) {
3
+ Map<String,List<String>> store = new HashMap<>();
4
+
5
+ for(String path:paths){
6
+ String[] arr = path.split(" ");
7
+ String directory = arr[0];
8
+
9
+ for(int i=1;i<arr.length;i++){
10
+ //fileName(content)
11
+ String fileName = arr[i].substring(0,arr[i].indexOf("("));
12
+ String content = arr[i].substring(arr[i].indexOf("(")+1,arr[i].length()-1);
13
+ List<String> filepaths = store.getOrDefault(content,new ArrayList<>());
14
+ filepaths.add(directory +"/"+fileName);
15
+ store.put(content,filepaths);
16
+ }
17
+ }
18
+
19
+ store.entrySet().removeIf(entry -> entry.getValue().size()<2);
20
+
21
+ return new ArrayList<>(store.values());
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments