Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Algorithm Chalenges
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Tom Riddle" data-source="post: 8900899" data-attributes="member: 47610"><p><span style="font-size: 15px"><span style="color: Blue">Sort the array first (you can do it in worst case O(n log n) using QuickSort ). Then read the array from the beginning till the end ONCE ( O<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite23" alt="(n)" title="Thumbs down (n)" loading="lazy" data-shortname="(n)" /> ), and if you come across a duplicate remove it.</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue">So the total complexity is O(n log n), which is much better than O(n^2) which would result when using the obvious algorithm of taking each word and comparing it with all the other words in the array.</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue">University of Moratuwa.</span></span></p></blockquote><p></p>
[QUOTE="Tom Riddle, post: 8900899, member: 47610"] [SIZE="4"][COLOR="Blue"]Sort the array first (you can do it in worst case O(n log n) using QuickSort ). Then read the array from the beginning till the end ONCE ( O(n) ), and if you come across a duplicate remove it. So the total complexity is O(n log n), which is much better than O(n^2) which would result when using the obvious algorithm of taking each word and comparing it with all the other words in the array. University of Moratuwa.[/COLOR][/SIZE] [/QUOTE]
Insert quotes…
Verification
Asuwa dahayen wadi kalama keeyada?
Post reply
Top
Bottom