Sliding Window Problem: O(n) TC And SC
SlidingWindow Problem: O(n*100) TC, O(n) SC. Find xth smallest negative num in each window of size k. Use HashMap to store freq of nums[i].
This is a fixed size SlidingWindow Problem
Problem
TC: O(n*100) = O(n)
SC:O(n) for using HashMap for storing the frequency of nums[i]
class Solution {
public int[] getSubarrayBeauty(int[] nums, int k, int x) {
Map<Integer,Integer> map = new HashMap<>();
int left =0,right = 0;
int index = 0;
int arr[] = new int[nums.length-k+1];
while(right<nums.length){
// keep frequency count of each no. in the nums
map.put(nums[right],map.getOrDefault(nums[right],0)+1);
if(right-left +1 >k){//if any time window size become more...