Page 2 of 2
Re: 11362 - Phone List
Posted: Sat May 10, 2014 6:59 am
by uDebug
Here's some input / output I found useful during testing / debugging.
Input:
Code: Select all
4
3
911
9232323
9
6
983
113
12340
123440
12345
98346
1
4
5
44
728232
454445
454446
728232
AC Output:
Re: 11362 - Phone List
Posted: Mon Dec 15, 2014 10:59 am
by gautamzero
why am i getting TLE??
Re: 11362 - Phone List
Posted: Tue Dec 16, 2014 1:29 am
by brianfry713
Change line 27 from:
sort(v.begin(),v.end(),compare);
to:
sort(v.begin(),v.end());
Change line 28 from:
for(i=0,flag=0;i<n;i++)
to:
for(i=0,flag=0;i + 1 <n;i++)
Change line 30 from:
for(j=i+1;j<n;j++)
to:
j = i + 1;
Read this thread.
Re: 11362 - Phone List
Posted: Tue Dec 16, 2014 6:17 pm
by gautamzero
thanx Brian Fry
actually it's not necessary to compare all numbers..

Re: 11362 - Phone List
Posted: Thu Nov 26, 2015 6:57 pm
by osongayito
I think the best solution is to use "trie" data structure.