Scala one-liner
Explanation\n- nums.groupBy(identity): This groups the elements of the array nums based on their identity, effectively creating a map where the keys are the dis
# Explanation\n- nums.groupBy(identity): This groups the elements of the array nums based on their identity, effectively creating a map where the keys are the distinct elements of nums and the values are arrays containing occurrences of those elements.\n\n- .mapValues(_.length): For each group (value) in the map, this maps it to its length, effectively giving the count of occurrences of each distinct element in nums.\n\n- .values: This extracts the values (counts) from the map.\n\n- .forall(_ < 3): This checks whether all the counts in the values satisfy the condition that they are less than 3. The forall method returns true if all elements in the collection satisfy the specified predicate (in this case, being less than 3), and false otherwise.\n\n# Code\n```\nobject Solution {\n    def isPossibleToSplit(nums: Array[Int]): Boolean = {\n     nums.groupBy(identity).mapValues(_.length).values.forall( _ < 3)\n\n    }\n}\n```
['Scala']