3
const int NEG_INF = -10e8;4
int maxDotProduct(vector<int> &nums1, vector<int> &nums2) {8
// NOTE : we can't initialize with INT_MIN because adding any val with it9
// will give overflow that is why we prefer 10^7 or 10^811
vector<vector<int>> dp(n + 1, vector<int>(m + 1, NEG_INF));13
for (int i = 1; i <= n; i++) {14
for (int j = 1; j <= m; j++) {15
int temp_p = nums1[i - 1] * nums2[j - 1];17
// Although it is a variation of LCS but here we need to check for all18
// answers we already know in dp Why only temp_p ? -> suppose in19
// dp[i-1][j-1] is -10^7 + temp_p is 2 == gives nearly -10^7(which is20
// wrong ans) For Remaining comparisons we already know why !22
dp[i][j] = max({dp[i - 1][j - 1] + temp_p, temp_p, dp[i - 1][j], dp[i][j - 1]});