Cpp Solution beats 100% - O(nlogn) Two Pointer Approach [ proof attached ;) ]
Hello World !!.  A two pointer based approach. Code is commented for better understanding. Hope it helps otherwise feel free to comment. \nThanks.\nHappy Coding
Hello World !!.  A two pointer based approach. Code is commented for better understanding. Hope it helps otherwise feel free to comment. \nThanks.\nHappy Coding.\n```\n     int n=nums.size();\n\t \n\t // Sort the given vector\n        sort(nums.begin(),nums.end());\n        int i=0;\n        int j=1;\n        int c=0;  // hold the final answer\n        int prev=INT_MIN; // keeps tracks of previous element\n        while(i<n && j<n){\n\t\t\n            if(nums[j]-nums[i] == k)\n            {\n                c++;\n                prev=nums[i];  //  Whenever i is going to be incremented we should update the value of prev.\n                i++;\n                j++;\n            }\n\t\t\t// if difference between values of both pointers is more than k, then increment j.\n            else if (j<n && nums[j]-nums[i]<k  ) j++;\n\t\t\t\n\t\t\t// else increment i\n            else{\n                prev=nums[i]; //  Whenever i is going to be incremented we should update the value of prev.\n                i++;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Note this while loop carefully. It makes sure that value of current nums[i] is not equal to the previous one, \n\t\t\t\t//because only unique difference pairs should be counted as per problem. So this while loop keep on moving \n\t\t\t\t// until either i becomes equal to n or previous value is not equal to current value.\n            while(i<n && nums[i]==prev  ) i++;\n\t\t\t\n\t\t\t// It makes sure that both i and j pointers are not pointing to same value. \n\t\t\t// This makes sure to pass the corner cases when k is 0.\n            if(i==j) j++;\n        }\n        return c;\n```\n![image](https://assets.leetcode.com/users/images/a5baf2a4-409e-4870-bf26-de94d2b4930b_1624697454.0305192.png)\n
[]