6
votes
1answer
44 views

Optimization of aStar in Java

I'm currently looking to optimize my aStar algorithm as my last run through took roughly a minute to generate one path. I've never had to optimize before as I've never run into performance issues, so ...
3
votes
6answers
500 views

Code Hunter 2.06: Count occurrences of 'a' in a string

I'm playing Code Hunt on level 2.06 (loops). This level is about counting the number of "a" in a String. ...
7
votes
2answers
348 views

Optimizing this inefficient TicTacToe configuration parser

On a programming contest I came upon this question: Given a partially played 3 × 3 tic-tac-toe configuration, write a program to determine which player will have a better chance of winning if the ...
5
votes
3answers
73 views

Calculating the ranks of classmates' exam grades

The questions from hackerearth: Geeko is in worry now because an exam is coming up and he has to know what rank he can get on exams. So he goes back into the the school records and finds the ...
2
votes
2answers
100 views
1
vote
4answers
632 views
2
votes
1answer
43 views

Optimize the split of a String from console

I have to read a String from console, so I used the tokenizer to split it and add each token in a position on ...
2
votes
1answer
168 views

Read a line from console in Java

I have to read a line of strings and split it for whitespace: ...
-1
votes
2answers
66 views

Pythagorean triplets

This code is about finding Pythagorean triplets. I take a number as input, and find from 1 to that number, how many Pythagorean triplets exist. Are there ways this can be optimized? It takes a lot ...
0
votes
1answer
85 views

Concat strings in Java

I've written this function that concats strings: ...
5
votes
3answers
274 views

Small notepad editor

I decided on making a small notepad editor in Java using Swing and I think it functions pretty well. Unfortunately, my skills in making my project tidy and organized has abandoned me; it looks like ...
6
votes
3answers
148 views

Is my below code thread safe w.r.t all the main application threads should get consistent data?

I am working on a project in which I construct a url with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main ...
7
votes
0answers
77 views

Recursively using reflection to merge fields

I'm using the Observer pattern to notify my UI that the object they're representing has changed. Also, I'm refreshing this object from the interwebs. Therefore, I'm ending up with two instances ...
7
votes
2answers
107 views

How to make sure all the threads are getting consistent data without performance impacts?

I am working on a project in which I construct a url with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main ...
3
votes
1answer
130 views

How to avoid making the call to the servers whenever it is down?

I am working on a project in which I construct a url with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main ...
7
votes
3answers
253 views

2048 game clone in Java

I made a 2048 game clone in Java for training, and I am trying to make it more efficient. The problem I found is the paintComponent() method always resets all the ...
6
votes
2answers
460 views

How good/bad this Sudoku generator?

I have written this following Sudoku Generator. How good/bad is this? How can I improve this? ...
6
votes
1answer
177 views

Is this Android click handler using threads correctly?

I am implementing a thread like the following. Is my implementation correct? It works well, but I need a check. ...
10
votes
1answer
545 views

Matrix multiplication

Below is the code that I've written for matrix multiplication: ...
9
votes
3answers
282 views

Optimizing “Herd Sums” problem using dynamic programming

I'm trying to solve a practice problem and all is well except for the last 2 inputs my solution is too slow. Just one loop is slowing it down I think. Herd Sums Execution Time Limit: 2 ...
0
votes
0answers
11 views

How to optimize this loop by using dynamic programming [duplicate]

I'm trying to solve a practice problem and all is well except for the last 2 inputs my solution is too slow. Just one loop is slowing it down I think. Problem: Full Solution: ...
5
votes
1answer
71 views

Using CountDownLatch for blocking the reads if writes are happening

I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write on my three maps. Requirements: Reads block until all three maps have been set for the first ...
4
votes
1answer
86 views

How to avoid reads before initialization is complete and return updated set of maps value?

This is a follow on to: How to prevent reads before initialization is complete? I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write on my three ...
6
votes
2answers
398 views

How to prevent reads before initialization is complete?

I am trying to implement lock by which I don't want to have reads from happening whenever I am doing a write. Below is my ClientData class in which I am using ...
3
votes
1answer
112 views

Civilization 5 Mod validator part 2

Here is another portion of the same program that I would like optimizing (85-95% of the time running the program is spent within this class!!!) so that it runs faster, especially for users who have ...
9
votes
1answer
122 views

Civilization 5 mod validator

I would like to submit a portion of my code for Code Review, and I have done my best to comment the code (and include essential parts that may aid understanding of the program) for your convenience! ...
3
votes
1answer
58 views

Insertion Sort implementation in Java

I have implemented Insertion sort in Java. Please review it. ...
9
votes
4answers
596 views
5
votes
2answers
135 views

AutoComplete program using the n-gram model

For my Advanced Data Mining class (undergrad) we were to design a program that would predict the next word a user is likely to type via automatic text classification using the n-gram model. The ...
10
votes
3answers
178 views

Checking to see whether a document can be deleted

My code looks like this: ...
7
votes
1answer
133 views

Creating map from ids

I am getting List ids and by using those ids I am creating a Map by fetching related data of ...
1
vote
1answer
33 views

Store object in memory or de-reference it for performance

I have a GUI that contains a Table Object (for displaying columns of data) and a Table Model. The Table Object contains the Table Model. Is it better to store the Table Model as a object in the User ...
6
votes
3answers
485 views

Anagram Checking

...
7
votes
3answers
205 views

Optimizing unique partitions of integers

I am working on a project involving the unique partitioning of integers. I.e. I am looking to have all of the partitions of n = x1 + x2 + x3 + ... + xk, where xi = xj implies i = j. For example, if I ...
7
votes
1answer
135 views

Determine total number of ways of reaching a destination

Question: One of Scotland Yard’s most wanted criminal (Mister X) is on the run and needs to reach a certain destination safely. There are three modes of transport available for him - By ...
4
votes
1answer
41 views

Baseline tagger

This is a baseline tagger coed I have written. How can I optimize this code? ...
9
votes
2answers
110 views

Optimizing “simplifier”

Basically, I'm trying to make a Simplifier that can take inputs in the form of a String and print out the solution step-by-step. Now that I've got it working, I ...
10
votes
5answers
477 views

Optimizing boolean checking method

I have written a method that checks if n number of true booleans are present in a ...
3
votes
1answer
99 views

Intersection of words

I get a map from DB called doc1 and I also have the ...
10
votes
1answer
101 views

Binary Tree/ Amorphous Binary Tree Creator

I suppose this is a two-part question. The first part is just a simple implementation of a Binary Tree (BTree), with pre-order, post-order, and in-order searches ...
17
votes
5answers
828 views

Custom indexOf() without String methods

I created my own indexOf function. I was wondering if anyone could help me come up with a way to make it more efficient. I am practicing for interviews so the catch ...
5
votes
2answers
182 views

General practitioner collection

The following code is used to find the usual_gp(General Practitioner) from gpCollection variable of type TreeMap<Long(Date), ...
3
votes
1answer
163 views

Sum of two squares

I'm trying to do a SPOJ problem called twosquares where you check whether the current number can be obtained by adding two squares together. However, I'm getting a "time limit exceeded" message. I'm ...
1
vote
0answers
55 views

Find the combinations, given three datacenters with x number of machines [closed]

I am working on a project in which I have three datacenter (as of now) and each datacenter will have some machines. So I am storing the input in a ...
2
votes
1answer
55 views

How to generate balls and box combinations depending on rule set I have?

I am working on a project in which I have three box (as of now) and each box will have some color of balls So I am storing the input in a ...
3
votes
2answers
240 views

Validating an input string against some enum fields

I have this enum below ...
7
votes
2answers
281 views

Optimization of file scanner

Program must to find duplicate files (by content) in a given directory(and subdirectories). I collect all data in Map<Long, ArrayList<String>> map ...
6
votes
4answers
189 views

Save space occupied by 2D array

My goal is to save space occupied by 2D array (sea) that has 3 different values. ...
1
vote
3answers
257 views

Lowest common ancestor in recursive tree traversal

LCA = Lowest Common Ancestor The following code finds the lowest common ancestor in tree of nodes, where a node can have two parents, left and right. The tree looks like this: ...
5
votes
2answers
92 views

How to optimize population projections for speed?

I am currently working on a problem of an online judge (not a contest). The program must calculate how many years will require for the population A (which is always less than B) to be higher than B. ...