solution for Timid Person — Jollybeeoj

Revision en2, by bluemmb, 2015-12-28 20:00:54

Hi , obviously this problem can be solved in O(N*M) with help of an array for counting, because numbers are <=1000 . but what is the best algorithm for solving this problem when numbers are <=1e9 ?

I wrote this code that works in O( N*M*log(N*M) ) but it got TimeLimit ( in 1second ) . How can we reduce this complexity ?

UPD : sorry , I linked to wrong source code. fixed.

Tags timid person, jollybeeoj

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English bluemmb 2015-12-28 20:00:54 69
en1 English bluemmb 2015-12-28 12:16:38 433 Initial revision (published)