JAVA| Time - o(n) | Space - o(1) | Two Pointer
```\n        // time:- o(n)\n        // space:- o(1)\n        \n        int i=0;\n        int j=0;\n        int count=0;\n        int prev_count=0;\n        \n 
```\n        // time:- o(n)\n        // space:- o(1)\n        \n        int i=0;\n        int j=0;\n        int count=0;\n        int prev_count=0;\n        \n        // only i varies\n        while(i<nums.length){\n            if(left <= nums[i] && nums[i]<=right){\n                // it is in range\n                count += i-j+1;\n                prev_count=i-j+1;\n            }else if( nums[i] < left){\n                // left se chote h value\n                count += prev_count;\n            }else{\n                // right se bade h value\n                prev_count=0;\n                j=i+1;\n            }\n            i++;\n        }\n        return count;
[]