Algorithm · Bloomberg · Medium
You are provided with an integer array nums and a predefined equivalence function equiv(x, y). This function returns true when x and y belong to the same equivalence class, and false otherwise. You may assume that equiv defines a proper equivalence relation—it is reflexive, symmetric, and transitive. Your objective is to divide the elements of nums into a collection of subarrays according to the equivalence relation. The following rules must be respected: Every element…
Checking your access…