Skip to main content
The 2024 Developer Survey results are live! See the results
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 21279

Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.

0 votes

SPOJ FASHION challenge

My guess is that most time is spent in String conversion and or IO. I made a version with the same idea as @Imus, and switched from Scanner to a custom Scanner which uses String.split() and BufferedR …
Rob Audenaerde's user avatar
5 votes

Printing mutual anagrams

[Work in progress] Nice question. I assume you come from a C background? That it what your code looks like. My main feedback would be to use Java's own classes and methods instead of implementing y …
Rob Audenaerde's user avatar
7 votes

Printing mutual anagrams

A different way would be to use primeHashes (see https://stackoverflow.com/a/4237875/461499). This prevents the need to sort. private static void printAnagrams2(List<String> input) { // our …
Rob Audenaerde's user avatar
2 votes

Mimic the code wheel included in The Secret Of Monkey Island

There is only one real variable, which is the 'innerDiskOffset'. Try to express all the other variables as function of this 'innerDiskOffset'. There are only 15 offsets, so you can code this in an arr …
Rob Audenaerde's user avatar
2 votes

Optimizing program to output all numbers summing to 100

General remark Short code (as in less space in code) is not necessarily easier to read, nor does it need to be faster. You can try to keep removing unnecessary stuff until it is as short as possible, …
Rob Audenaerde's user avatar
1 vote

Clone of mobile game Ballz

I'm more of a Java guy, but I'll add my 2 cents on the collision detection, because you said it was not always working properly; I think you might solve this by creating a 'vecor' object, or ray. The …
Rob Audenaerde's user avatar
5 votes
Accepted

Find lexicographical permutations

Encoding I hope I understood the problem correctly :) When observing the problem, I found you can replace the H and V with 0 and 1. The lexicographical permutations then become binary numbers. There …
Rob Audenaerde's user avatar
1 vote
Accepted

Improving Fibonacci recursion with BigIntegers

This line causes a lot of unnecessary calls: a[b] = theBigFib(b - 1).add(theBigFib(b - 2)); For each second call you get 4 calls, 8 calls, 16 calls etc. You can still use recursion, but if you add …
Rob Audenaerde's user avatar
1 vote

LeetCode: Roman to Integer in Java

You could also use a switch statement to prevent auto-boxing. Taking the logic from @tinstaafl's solution: class Solution { public int romanToInt(String input){ int retVal = 0; int li …
Rob Audenaerde's user avatar
2 votes

Finding all the prime factors of a number

Quick observation: you use Math.pow() to calculate powers of two. This is highly inefficient, use bit shifting to prevent long -> double conversion For example, 2^10 can be calculated very quicky as …
Rob Audenaerde's user avatar
3 votes
Accepted

Find all words in a dictionary that can be made with a string of characters (Recursion/Binar...

Check if you are solving the right problem! Most times when codes get horribly slow, you are solving the wrong problem, or the problem in an ineffective way. Try to think of different approaches. It' …
Rob Audenaerde's user avatar
5 votes
Accepted

Java Magic square program

Don't repeat yourself You use x/size and x%size a lot. You can easily assign them to local variables, and your code becomes much better readable. x is not the best name for an index, consider using i …
Rob Audenaerde's user avatar
1 vote

How to optimize Karatsuba algorithm (using arraylist and java)

Reduce running time Maybe you can use subList to prevent new lists that are basically a copy of a part of the input? This saves a lot of autoboxing (which I assume is the bottle neck, if the algorith …
Rob Audenaerde's user avatar