suppose size of input could be n=1…100000 and complexity of my code is O(n3). will it be able to execute in 2 sec.
Generally you can do 10^7 to 10^8 calculations per second in any competitive platform.
In your case n will get max value of 10^5 so it require approx. 10^15 calculations.
so it will definitely exceed time limit of 2 seconds (It will exceed time limit of 1000 seconds).
I think you should make solution having time complexity of O(nlogn).