All Questions
226
questions
3
votes
1
answer
468
views
LeetCode 767: Reorganize String
Here I'm posting my code for the Reorganize String problem on LeetCode. If you have time and would like to review, please do so, I'd appreciate that.
On LeetCode, we are only allowed to change the ...
0
votes
1
answer
174
views
LeetCode 76: Minimum Window Substring - Java
I'm posting my Java code for the Minimum Window Substring. If you have time and would like to review, please do so, I appreciate that.
Problem
Given a string string...
5
votes
2
answers
480
views
How to optimize Karatsuba algorithm (using arraylist and java)
I was using Karatsuba algorithm to multiply two polynomials and return the coefficients and I am using java, we are asked to use arraylists here, however, my code is too complicated and it takes much ...
1
vote
2
answers
477
views
How to efficiently find if numbers in a given range contains either 1 or 3, but not both?
I am having a trouble speeding up my implementation. The question is, given a range of numbers from long a to long b, find how many lucky numbers are between a and b inclusive. A number is a lucky ...
5
votes
2
answers
104
views
Performance Enhancement of A Star Path Finder algorithm with 1024 multidimentional array
I have the below code for a A* pathfinder, however it is taking upwards of 10 minutes to find a solution using a simple 1024 x 1024 array.
I had to comment out ...
0
votes
2
answers
612
views
Java Palindrome - Time & Space Complexity
Which of these three methods is the most efficient?
Also, what is the time & space complexity of each?
...
4
votes
2
answers
86
views
Filtering product ids
As regarding the following question I have completed the code as below.
But I am curious about other effective solutions. I am also curious about if there is any solution that could be applicable by ...
1
vote
1
answer
181
views
"Edit Distance" algorithm
I have a piece of code that calculates the edit distance between words and works, but it's apparently not fast enough.
ClosestWords.java:
...
4
votes
5
answers
1k
views
Counting number of `1` digits in the value of \$11^n\$
I am trying to improve the efficiency of my code,
The Question is:
Given a value n, where n is in the range ...
2
votes
2
answers
195
views
Brute-force ID reversal search
EDIT
The random number generator in this code is a blackbox for a similar algorithm that isn't publishable for privacy concern. The algorithm works in similar way, in that it takes in a seed value ...
3
votes
1
answer
252
views
Knuth-Morris-Pratt algorithm in Java Finding substrings in a matrix
Problem
Given two matrices: a pattern p and a text t. Write a program that
counts the number of occurrences of ...
6
votes
1
answer
430
views
Remove elements compared with other elements in a Set based on a condition
Simplified the actual problem to focus on comparing/removing performance.
Given a set S with n elements , find the most optimal way to compare each element to all others until a condition is met that ...
1
vote
1
answer
448
views
Adding a number to an array of digits
I'm a student in my first semester and in my free time and holidays, I do some java training to keep my mind from rusting...so I downloaded this amazing Digital Algorithms practice app
and came across ...
1
vote
0
answers
256
views
Algorithm X implementation for Minimum Dominating Set
As as final project for a MOOC I wanted to write a program that finds the exact cover set/minimum dominating set from the given social network data. So I did end up with writing this. I kinda followed ...
7
votes
2
answers
2k
views
Arranging numbers in a circle such that the sums of neighbors and sums of diametric opposites are prime
I need to create a circle with numbers from 1 to n , however it is necessary to respect some rules:
All numbers from 1 to n are used in the circle only once.
The sum of two consecutive numbers ...