Facing TLE even using Java Array Editorial solution.
Use map to solve.Even with maps I was getting TLE .Using the word unordered infront of map sorted the issue.
when B>A.size() then ans will be decreasing array so we can directly sort and return ;
using this condition i passed all the cases
Donot use maps ,but use an array as array access is guranteed to be O(1). It solved the case for me.