O(n) python solution with explanation
IntuitionSo, in this problem, we have to split the array into TWO parts. The splitting should be done in such a way that both parts should have distinct element
# Intuition
So, in this problem, we have to split the array into TWO parts. The splitting should be done in such a way that both parts should have distinct elements. We can solve this problem using hashmap.

# Approach
So, we will create a hashmap named count which will count the number of elements in the array. If they are greater than 2, we have to return False because as the question says that we can split the array into only two parts and should also contain distinct ie different elemnts.

But if, we get less than or equal to 2, we can return True that means we can split it easily.

Example of the operation:
-> nums = [1,1,2,2,3,4]
This is the input array we're given which we have to split into two and have distinct elements in it.

We will create a hashset in which we will store all the elements of the array named count using counter func:
-> count = [1:2, 2:2, 3:1, 4:1]
In the 1:2, where 1 is the key ie element and 2 is the value ie number of occurences.

Now, we will check if the count of any elemt from the hashset is greater than 2. If yes, we have to return false for the above stated reason. If less or equal to 2, we can return true.

So, our output would be :
-> [1, 2, 3]
-> [1, 2, 4]

![Screenshot 2025-02-21 at 4.26.05 AM.png](https://assets.leetcode.com/users/images/70c0d3ee-3882-460b-9cff-1db1154972c2_1740092199.1792712.png)


# Complexity
- Time complexity:
O(n) where n denotes the number of elemts in the array as we're looping through it and storing them in a hashmap and it has 0(1) lookup through hashset.

- Space complexity:
O(n) where n denotes the length of the hashmap as it's dependent on the number of elemts in the input array.

# Code
```python3 []
class Solution:
    def isPossibleToSplit(self, nums: List[int]) -> bool:
        count = Counter(nums) #counting the number of elemnts in the array

        for c in count.values():
            if c > 2:
                return False # return false if greater than 2
        
        return True #if less than or equal to 2
```
['Python3']