Easy Video Explanation || Greedy 🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nThink in terms of Greedy\n\n# Easy Video Explanation\nhttps://youtu.be/C68j-WyjhTw\n\n\
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThink in terms of Greedy\n\n# ***Easy Video Explanation***\nhttps://youtu.be/C68j-WyjhTw\n\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe code counts the number of pairs of almost equal characters in a string. It iterates through the string, checking if the absolute difference between consecutive characters is 1 or if they are the same. If true, it increments the count and skips the next character.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(N)\n    \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(1)\n    \n\n# Code\n\n\n```C++ []\nclass Solution {\npublic:\n    int removeAlmostEqualCharacters(string s) {\n        int ans=0;\n        int n=s.size();\n        int i=1;\n        while(i<n) {\n            if(abs(s[i]-s[i-1])==1 || s[i]==s[i-1]) {\n                ans++;\n                i=i+2;\n                continue;\n            }\n            i++;\n        }\n        \n        return ans;\n        \n    }\n};\n```\n```python []\nclass Solution:\n    def remove_almost_equal_characters(self, s):\n        ans = 0\n        n = len(s)\n        i = 1\n        while i < n:\n            if abs(ord(s[i]) - ord(s[i - 1])) == 1 or s[i] == s[i - 1]:\n                ans += 1\n                i = i + 2\n                continue\n            i += 1\n        return ans\n\n```\n```Java []\n\npublic class Solution {\n    public int removeAlmostEqualCharacters(String s) {\n        int ans = 0;\n        int n = s.length();\n        int i = 1;\n        while (i < n) {\n            if (Math.abs(s.charAt(i) - s.charAt(i - 1)) == 1 || s.charAt(i) == s.charAt(i - 1)) {\n                ans++;\n                i = i + 2;\n                continue;\n            }\n            i++;\n        }\n        return ans;\n    }\n}\n\n```\n\n# ***If you like the solution Please Upvote and subscribe to my youtube channel***\n***It Motivates me to record more videos***\n\n*Thank you* \uD83D\uDE00
['Greedy', 'Python', 'C++', 'Java']