FastPrepCount Redundant File Backups
Problems/Count Redundant File Backups

Count Redundant File Backups

Goldman Sachs logoGoldman Sachs● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The partly hidden last timestamp in the second example is rebuilt as 10080, which keeps the reported result. The report does not give the function signature or the full filename rules. This version sets the interface and says filenames must be exactly equal, with case mattering. Our version is about 95% the same as the reported question.

You are given two parallel arrays, fileName and timestamp. Record i describes a backup of file fileName[i] at time timestamp[i], measured in seconds. Records may arrive in any order.

A file is redundant if it has at least three backup records within some continuous 24-hour period. Equivalently, there must be three records for that file whose largest timestamp minus their smallest timestamp is at most 86,400.

Return the number of distinct redundant files. Count each file once, even when several qualifying periods exist. A period may start at any time; it is not restricted to calendar-day boundaries.

For this exercise, compare filenames exactly, including letter case. Each array entry is a separate backup record, so repeated records and equal timestamps count separately.

Function

countRedundantFiles(fileName: String[], timestamp: int[]) → int

Examples

Example 1

fileName = ["sales","design","design","sales","sales"]timestamp = [47210,18902,73455,82960,24896]return = 1

The sales timestamps are 24896, 47210, and 82960. Their span is 58064 seconds, so sales is redundant. The design file has only two backup records.

Example 2

fileName = ["alpha","gamma","alpha","alpha"]timestamp = [32768,1296,96480,10080]return = 1

The alpha timestamps are 10080, 32768, and 96480. Their span is exactly 86400 seconds, which is allowed. The gamma file has only one record.

Example 3

fileName = ["log","log","log","log"]timestamp = [1,86402,172803,172804]return = 0

The first consecutive triple spans 172802 seconds, and the last spans 86402 seconds. Neither fits in 86400 seconds, so having four total backups is not sufficient.

Constraints

  • n == fileName.length == timestamp.length
  • 1 <= n <= 200000
  • 1 <= fileName[i].length <= 10
  • 1 <= timestamp[i] <= 1000000000

More Goldman Sachs Online Assessment questions

  • Maximum Ones After K OperationsOA · Seen Nov 2026
  • Palindrome CounterOA · Seen Oct 2026
  • Longest Palindromic SubsequenceOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Merge Overlapping IntervalsOA · Seen Sep 2026
  • Data ReorganizationOA · Seen Jul 2026
  • Alternating Parity PermutationsOA · Seen Jul 2026
  • Threshold AlertsOA · Seen Jul 2026
  • Find the Winner of an Array GameOA · Seen Jun 2026
  • Minimum Number of Taps to Water a GardenOA · Seen Jun 2026

Similar questions at other companies

  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Earliest Hour with Frequent Badge AccessIntuit · OAIntuit interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Log Analyzer: Busiest Service in a Rolling WindowByteDance · PHONE SCREENByteDance interview questions
  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Top K Best-Selling Products in the Last N DaysAmazon · ONSITE INTERVIEW
  • Message Event AggregationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Sliding-Window Frequency SnapshotsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Detect Security Attacks from Network LogsFireworks AI · PHONE SCREEN
  • Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public int countRedundantFiles(String[] fileName, int[] timestamp) {
        // Write your code here.
        return 0;
    }
}
Checking account…