Python Easy Solution With Explanation
Here in this ques we don\'t have to think much and just have to apply basic understanding of concepts and follow the ques as it is told .\n\nSo first we sort th
Here in this ques we don\'t have to think much and just have to apply basic understanding of concepts and follow the ques as it is told .\n\nSo first we sort the array to make things easier and save our time from again and again checking for conditions in our array .\n\nThen we use the concept of sliding window , to check for 3 array values at a time the current one and compare it with the previous and next value at once and follow the conditions told in the ques.\n```\nclass Solution:\n    def findLonely(self, nums: List[int]) -> List[int]:\n        if(len(nums)<=1):\n            return(nums)\n        \n        nums.sort()\n        l=[]\n        for i in range(len(nums)):\n            if(i==0):\n                if (nums[i]!=nums[i+1]) and (nums[i+1]!=(nums[i]+1)):\n                    l.append(nums[i])\n                \n            elif(i==len(nums)-1):\n                if (nums[i]!=nums[i-1]) and (nums[i-1]!=(nums[i]-1)):\n                    l.append(nums[i])\n            \n            else:\n                if (nums[i]!=nums[i+1]) and (nums[i+1]!=(nums[i]+1)) and (nums[i]!=nums[i-1]) and (nums[i-1]!=(nums[i]-1)):\n                    l.append(nums[i])\n        \n        return(l)\n```\nIf u understood the code then plz....UPVOTE....Thnx in adv
['Python']