DP hackerrank (stock maximize)
STock Maximize (iterative dP and branch & bound approach ) #include<bits/stdc++.h> using namespace std; long long int sell[1000000],a[1000000]; int main() { int t; cin>>t; while(t--) { long long int n,i,j,k,ans=0,m=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; for(i=n-1;i>=0;i--) { if(m<a[i]) m=a[i]; sell[i]=m; } for(i=0;i<n;i++) { if(sell[i]>a[i]) ans+=sell[i]-a[i]; } cout<<ans<<endl; } return 0; } -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Branch And Bound -----------...