CODENATION OA: 14/08/22
Question · Posted Aug 2022
Question 2: Minimum Strangeness Overview Determine the minimum strangeness of array A possible. ## Approach ## We solve this problem using dynamic programming with the base case of B=1. dp[i][j] stores the minimum strangeness value of the array starting at position i and with the B value equal to j. When j=1, we take the entire subarray in one group. Pseudocode long long rec(vector<int>&arr, int pos, int k) { if (k == 1) { //base case int sum = 0; ...
The full answer & interview discussion are available to premium members.
Log in Create a free account