Dropbox Interview Question for SDE1s


Country: United States




Comment hidden because of low score. Click to expand.
0
of 0 vote

Use recursion to traverse all the files in the folder. For each file generate it's MD5 checksum and use a hash table to keep track of duplicates using MD5 as key and frecuency as value.

- Inucoder May 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use md5sum utility to compute 'md5 hashes for each fiile.
Build a hash table / map of md5hash : <list of files>
Done.
Go thru hash table, output each list as duplicates

- Nix May 09, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.io.File;
import java.util.HashSet;
public class ReadDuplicateFileInDir {
public static void main(String[] args) {
File folder=new File("C:/Users/sumitksi/Downloads");
HashSet<File> al=new HashSet<File>();
getAllFilesRecursevely(al,folder);
for(File file:al)
{System.out.println(file);}
}
public static HashSet<File> getAllFilesRecursevely(HashSet<File> al,File folder){
for(File file:folder.listFiles())
{
if(file.isFile())
if(al.add(file));
//Do nothing.
else
System.out.println("Its duplicate :"+file);
else
getAllFilesRecursevely(al,file);
}
return al;
}
}

- Sumit Kumar Sinha May 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.io.File;
import java.util.HashSet;
public class ReadDuplicateFileInDir {
public static void main(String[] args) {
File folder=new File("C:/Users/sumitksi/Downloads");
HashSet<File> al=new HashSet<File>();
getAllFilesRecursevely(al,folder);
for(File file:al)
{System.out.println(file);}
}
public static HashSet<File> getAllFilesRecursevely(HashSet<File> al,File folder){
for(File file:folder.listFiles())
{
if(file.isFile())
if(al.add(file));
//Do nothing.
else
System.out.println("Its duplicate :"+file);
else
getAllFilesRecursevely(al,file);
}
return al; }}

- sumitsinha36 May 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def findDup(parentFolder):
    # Dups in format {hash:[names]}
    dups = {}
    for dirName, subdirs, fileList in os.walk(parentFolder):
        print('Scanning %s...' % dirName)
        for filename in fileList:
            # Get the path to the file
            path = os.path.join(dirName, filename)
            # Calculate hash
            file_hash = hashfile(path)
            # Add or append the file path
            if file_hash in dups:
                dups[file_hash].append(path)
            else:
                dups[file_hash] = [path]
    return dups

- Anonymous August 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def findDup(parentFolder):
    # Dups in format {hash:[names]}
    dups = {}
    for dirName, subdirs, fileList in os.walk(parentFolder):
        print('Scanning %s...' % dirName)
        for filename in fileList:
            # Get the path to the file
            path = os.path.join(dirName, filename)
            # Calculate hash
            file_hash = hashfile(path)
            # Add or append the file path
            if file_hash in dups:
                dups[file_hash].append(path)
            else:
                dups[file_hash] = [path]
    return dups

- Anonymous August 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def findDup(root):
    # Dups in format {hash:[names]}
    dups = {}
    for dirName, subdirs, fileList in os.walk(parentFolder):
        print('Scanning %s...' % dirName)
        for filename in fileList:
            # Get the path to the file
            path = os.path.join(dirName, filename)
            # Calculate hash
            file_hash = hashfile(path)
            # Add or append the file path
            if file_hash in dups:
                dups[file_hash].append(path)
            else:
                dups[file_hash] = [path]
    return dups

- khushbuparakh August 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Test comment

- Coder January 11, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

List<String> dupFiles(String[] files) {
    List<String> res = new ArrayList<>();
    Set<String> set = new HashSet<>();
    for( String file : files) {
        if(!set.add(file)) {
            res.add(file);
        }
    }
}

- hivehome May 12, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More