Can someone share their approach for HIRING and SAVJEW.

In HIRING what I have done is for each element iterate over each of it’s submask and calculate the sum of all it’s value and thus we get "number of subsequence ending at i". But it gives WA. Can someone please point out my mistake in this solution?

Here is my submission.

Thanks.