Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25
  1. #21
    jayant3001's Avatar
    jayant3001 is offline Member
    Join Date
    Oct 2008
    Posts
    22
    Rep Power
    0

    Default

    ya this is taking long time. in fact i waited for 1 hr but could not get ans

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default

    You need to optimize the logic for the for(j) loop. Using -Xprof with your code shows that 97% of the execution is spent in that loop.
    The brute force method doesn't work on a normal computer.

  3. #23
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Basically try to use an optimize algorithm to do the task.

    Just a hint. Normally in such cases, if I cannot/difficult to optimize an algorithm, what I have done is check the result in different stages and work on the quickest result I got. That's actually not a good way, not a much safer way, but in lots of cases I found that is reliable.

  4. #24
    jayant3001's Avatar
    jayant3001 is offline Member
    Join Date
    Oct 2008
    Posts
    22
    Rep Power
    0

    Default

    ok thanks for this

  5. #25
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 24
    Last Post: 07-29-2008, 04:04 PM
  2. Problems in JSP : Need help
    By raj4u in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-07-2008, 10:06 AM
  3. GUI problems.
    By saytri in forum New To Java
    Replies: 1
    Last Post: 12-16-2007, 10:27 PM
  4. many to many problems
    By cecily in forum JDBC
    Replies: 1
    Last Post: 08-02-2007, 05:51 PM
  5. problems with JPA
    By Ed in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 05:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •