Facing TLE in JAVA


#1

Facing TLE even using Java Array Editorial solution.


#2

Use map to solve.Even with maps I was getting TLE .Using the word unordered infront of map sorted the issue.


#3

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


#4

Donot use maps ,but use an array as array access is guranteed to be O(1). It solved the case for me.