All Questions
Tagged with javaperformance
133 questions
62votes
3answers
4kviews
Analyzing Minesweeper Probabilities
Calculating probabilities in Minesweeper might sound like an easy task, but I've seen so many probability calculators that's either incorrect, horribly slow, or with ugly code (or all of them) so I ...
23votes
6answers
14kviews
Optimize Conway's Game of Life
I have coded up an implementation of Conway's Game of Life and I have a performance bottleneck in it which I wish to be optimized. The main logic is in the Universe ...
12votes
3answers
6kviews
Project Euler Problem 12 - triangle number with 500 divisors
I've just done Problem 12 of Project Euler: What is the value of the first triangle number to have over five hundred divisors? The \$N\$'th triangle number is the sum of all natural numbers ...
11votes
4answers
27kviews
Find the binary gap of a number N
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of ...
21votes
4answers
2kviews
Finding the sub-array with the maximum sum - my approach
This is the code I ended up with that implements the approach I described in a recent answer to another question about the same problem The basic idea here is to not loop through more things than ...
13votes
3answers
5kviews
The Beauty and the Strings
This originally appeared in Facebook's hacker cup 2013. Solving it was fun, though I find myself looping through similar data quite often. Challenge: Print the maximum beauty of strings. ...
11votes
2answers
581views
A Specific Combination
This code is going to be included in my Minesweeper Probabilities project. (so far it only exists on the develop-branch) The purpose is to return a specific combination, let's say for example that ...
6votes
3answers
9kviews
Printing longest sequence of zeroes
I am doing a coding exercise in codility and I came across this question: A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ...
3votes
2answers
1kviews
Premium palindromic primes
Challenge: Write a program which determines the largest prime palindrome less than 1000. The answer is 929, and my program correctly finds and prints this, but actually ended up being more complex ...
20votes
5answers
3kviews
Print the N longest lines in a file
I have implemented the "Find the N longest lines in a file" problem from CodeEval quoted below. I got a full 100 score and 182ms execution time of their data set on the site so I consider the code ...
13votes
8answers
9kviews
Sieve of Eratosthenes
For practice, I've implemented Sieve of Eratosthenes in Java by thinking about this visual animation. I would like to hear some suggestions for improvements, especially how to make it more efficient ...
13votes
5answers
22kviews
Smallest Multiple
I just recently learned about Project Euler and have started doing the problems on there. I cleared problem 1 and 2, had no idea how to do 3 and 4, and started to do 5. I've seen the post regarding ...
12votes
5answers
7kviews
Efficient FizzBuzz
I wrote the following Fizz Buzz program. How can I improve it or make it more efficient? ...
12votes
2answers
10kviews
Efficiently using Apache HttpClient in multithreaded environment
I have a library which is being used by customers and they are passing DataRequest object which has userid, various ...
9votes
1answer
810views
Java application for finding permutations efficiently
I am an eighth grader with a school project of creating and application in Java that returns the total permutations of two given numbers. It needs to be light and efficient, for later deployment on a ...