I got the logic except that I have just one problem.
The answer what everybody(below accepted coded) is printing is just the final index(all final indexes of all dimensions) of 3-D dp array i.e. just that one value.
But isn't it just the length of longest decreasing subsequence after considering all pos of the array.
Should it have been that
where i and j run for the entire length of the dp array.
Because the problem asks for the total no of rooms encountered by both the people.
Here just returning the longest decreasing sequence means only those rooms encountered by catwoman.
Please help here. I am seriously puzzled by this tho...