• DSA Video tutorial idea, the below problem or similar problem can be explained with a story like this, since this is also calledhare_and_tortoise_algorithm the two pointers can be represented with a Hare and tortoise and then a story can be made like both hare and tortoise started moving to the a street and there were shops on the road, they were given the task to move all alcohol shops to the end of the street. They start moving and whenever hare encounter an alcohol shop, the hare asks tortoise to stay there till he finds another shop which is not alcohol shop once he finds it they swap it and both hare and tortoise move one shop ahead, if hare encounters an alcohol shop then only he moves ahead till he finds a non alcohol shop once he finds that he calls tortoise and they swap the shop, this continues till hare reaches the last shop on the street.

Attempt 1 ✅

class Solution(object):
    def removeElement(self, nums, taboo_num):
        """
        :type nums: List[int]
        :type val: int
        :rtype: int
        """
        '''
            gyan pelo
            - start with two pointers from front and end
            - if the value in end is equal to target val replace with _ in loop
            - start other pointer with starting and if it is equal to val then go to last pointer if that is not val then swap both and replace val with _
            - it will be easy with two loops, should I start with two loops and then merge them?
            dry run:
            there are two pointers with 0 value 
            second pointer increased every time so it can basically be a for loop
            if second pointer is equal to taboo num then, in nums array overwrite value of first pointer with second pointer
            this is fast and slow pointer 
            first_pointer is increased only if value at second pointer is taboo num
            if the value at fast pointer is not taboo num then overwrite value at slow pointer with fast pointer val
            so if there is no taboo num fast pointer keeps increasing till it reach the end
        '''
        
        slow_pointer, fast_pointer = 0, 0
 
        while fast_pointer < len(nums):
            if nums[fast_pointer] == taboo_num:
                fast_pointer += 1
            else:
                nums[slow_pointer] = nums[fast_pointer]
                slow_pointer += 1
                fast_pointer += 1
            print(str(slow_pointer) + " " + str(fast_pointer))
 
        print(nums[0:slow_pointer])
        return slow_pointer