Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Script to Archive Files Over 1GB

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Script to Archive Files Over 1GB. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Andela Products needs a manifest of oversized files from a CI artifact directory before archiving them. Given file metadata, find every file whose size is strictly greater than 1 GiB.

The archive operation is represented by the returned list of file paths. Preserve the input order so the manifest is deterministic.

Formal Specification

Implement archive_large_files(files), where files is a list of dictionaries. Each dictionary contains:

  • path, a unique string representing the file path
  • sizeBytes, a non-negative integer containing the file size in bytes

Return a list of paths for files larger than 1,073,741,824 bytes, or an empty list when no file qualifies.

Constraints

  • 0 <= len(files) <= 10^5
  • 0 <= files[i]["sizeBytes"] <= 10^15
  • Every file has a unique non-empty path
  • Do not modify the input list

Function Signature

def archive_large_files(files):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output