This was for sw2. I was supposed to search a dir to find files that have have the same content. Ex. hello.txt = "hello" and fjalfja.txt = "hello" and main.cpp, main2.cpp, final_main.cpp.
It should return
[root/hello.txt, root/folder1/fjalfja.txt],
[root/dev/main.cpp, root/dev/main.cpp, root/dev/dev_final/final_main.cpp]
I did not get far. What would be the best solution to check if they have the same content? The only think I was able to think was read the bytes of the files into Byte[] and turn the array into a String and have a HashMap<String, ArrayList String>.
List<List<String>> findDuplicates(String root) {
}
I was given some functions as helpers and I was supposed to assume they work. I was not able to finish the first part because of reasons, but who knows if I was supposed to finish them later.
boolean isDir(String s){
return boolean
}
String[] LS (String s) {
// imagine you type ls in the terminal.
return String []
}
String pwd(String s){
// it should return the path from the root + file
// root/folder1/folder2/file.txt
return s;
}