Results 1 to 3 of 3

Thread: Greedy Algo Problem - Find a highest product

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    518
    Thanks
    13
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Greedy Algo Problem - Find a highest product

    Hi, simple but probably not fast solution:
    std::sort on the array, then multiply last three elements.

    Ginsengelf

  2. The following user says thank you to Ginsengelf for this useful post:

    d_stranz (21st June 2018)

  3. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,321
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Greedy Algo Problem - Find a highest product

    Very clever. Certainly much faster than a combinatorial method, even with the sorting.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Which architecture has the highest range of devices?
    By guidupas in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 29th June 2015, 16:11
  2. QFile::setPermissions highest user in profiler
    By Phlucious in forum Qt Programming
    Replies: 0
    Last Post: 26th October 2012, 17:38
  3. Replies: 0
    Last Post: 4th April 2011, 16:17
  4. Non-greedy (lazy) RegExp in QtScript
    By ultr in forum Qt Programming
    Replies: 5
    Last Post: 26th May 2010, 15:40
  5. The product
    By techie1991 in forum Newbie
    Replies: 9
    Last Post: 25th March 2010, 13:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.