Round 1: Approx 45 minutes
Question:
Given a URI, traverse all its subdirectories and files, and return a list of the top 10 largest files in byte, including their names and sizes. If the directories are empty, return '-1' as the result.
Input:
uri: “C:/xvcv/bfbfbb/jbhdbb”
Output:
54789565 “C:/xvcv/bfbfbb/jbhdbb/dn”
7458225 “C:/xvcv/bfbfbb/jbhdbb/dn/xvhh”
1254788 “C:/xvcv/bfbfbb/jbhdbb/jkl”
……….
112542 “C:/xvcv/bfbfbb/jbhdbb/pqr”
Hint: Use Linux Commands
Approach:
I used recursion to traverse all subdirectories within a given URI. I employed storage class commands to retrieve the size of each file and list out the child files, which I stored in a list. Then, I sorted the list and returned the top 10 largest files from it. Before traversing, I checked for edge cases to ensure robustness.
Round 2: Approx 45 minutes
Question: given a class having 3 member functions create_directory(string filepath),create_file(string filename,string filepath),bool find_filename_from given prefix(string pref,string filepath) implement these 3 member functions.
Input:
Create_directory // eg:-filepath: /abc/f/d/x/
Create_file // eg:-filepath: /abc/f/d/x/ filename:google.yaml
find_filename_from given prefix eg:-filepath: /abc/f/d/x/dsa.yaml prefix:ds