Mark As Completed Discussion

Time Complexity:

The brute force approach has an O(n) time complexity, where n is the array's length. Moreover, the space complexity of the brute force approach is O(n) because a new array will be created, which will have the same length just like the original array.