Induction Buy now Induction Buy now
sliding window Introduction Sliding window technique is use for reducing some redundant calculation which slow down program. like it can reduce time complexity from O(n^2) to O(n) with O(1) space complexity. Why use it? First of all it reduce time coplexity and also with O(1) space complexity. so let’s understand with Example… So we want to find maximum sum of k consecutive integer from array, so brute force would look like this for k=5, #include<iostream> #include<vector> using namespace std; int main(){ vector<int> arr = {5,2,6,7,7,3,2,1,3,9}; int final_max = 0; for(int i=0;i<arr.size()-5;i++){ int temp_max = 0; for(int j=i;j<i+5;j++){ temp_max += arr[j]; } if(temp_max>final_max){ final_max = temp_max; } } cout << final_max << endl; return 0; } But time complexity of above program is O(nk) Brute Force Approach As per we can see...