VERITAS TECHNOLOGIES | Off Campus OA (2023) | Largest Divisible Subset

Veritas · Question · Posted Jun 2026

Problem Statement You are given an array of distinct positive integers nums. A subset of nums is called a divisible subset if for every pair of elements (a, b) in the subset, either: a % b == 0, or b % a == 0 Return the largest divisible subset. If multiple answers exist, return any one of them. Input Format An integer array nums. Example 1 Input: nums = [1,2,3] Output: [1,2] Explanation: [1,3] is also a valid answer. Example ...

The full answer & interview discussion are available to premium members.

Log in Create a free account