Fewest Folder Policies Covering Sensitive Files Under Collateral Budget
Last updated: November 29, 2026
Quick Overview
Given a folder tree whose leaves are files marked sensitive or not, choose the fewest nodes on which to apply a restrictive policy so every sensitive file is covered by some chosen ancestor (or itself), while covering at most K non-sensitive files in total.
Concentric Ai
November 29, 20260
0
0 solved
Given a folder tree whose leaves are files marked sensitive or not, choose the fewest nodes on which to apply a restrictive policy so every sensitive file is covered by some chosen ancestor (or itself), while covering at most K non-sensitive files in total.
Remediation in a DSPM product like Concentric AI is easiest to operate when a few folder-level policies replace thousands of file-level ones, but a broad policy also locks down unrelated files that people need. This hard onsite problem checks tree dynamic programming with a knapsack-style merge and a careful complexity argument.
What the Interviewer Expects
- Formulate the per-node state as min policies per collateral amount
- Merge children with a bounded min-plus convolution
- Handle the 'select this folder' transition
- Prune subtrees without sensitive files
- Argue the O(N*K) style bound from capping array sizes
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the actual set of chosen nodes, not just the count?
- What if each folder has a different policy cost?
- How would you approximate when K is in the millions?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Nodes are folders or files; files are leaves. A policy on a node covers all files beneath it. Every sensitive file must be covered; collateral is the number of non-sensitive files covered; choose node...
High-Level Design
Let dp[n][c] be the minimum number of policies inside subtree n that cover all its sensitive files with exactly c collateral, assuming no ancestor policy. For a sensitive file dp = [1]; for a clea...