All Questions
226
questions
2
votes
0
answers
126
views
Tic Tac Toe game becomes more inefficient as time goes on
I designed a tic tac toe using 4 classes. The game class being the main class, the board class being the board, the player class being the decision making, and the AI class keeping the previous game ...
2
votes
1
answer
193
views
Let us schedule a meeting
Description:
Write a method mergeMeetings() that takes a list of multiple meeting time ranges and returns a list of condensed ranges. The integers represent the number of 30-minute blocks past 9:00am....
1
vote
3
answers
2k
views
Merge sorted lists, removing duplicates
I want to merge two sorted lists of Integers but this is not the general mergesort case because the same number may appear in both lists. (However, each number can only appear once in a particular ...
2
votes
1
answer
336
views
Backtracking maze traversal
I have a functional backtracking solution, but I am only able to finish 22/25 test cases before exceeding my specified time limit. Any suggestions on how to improve the speed are greatly appreciated!
...
1
vote
1
answer
203
views
Custom sorting algo / optimized bubble sort
I'm a novice and started diving into data structures and algorithms recently. I was taught bubble sort recently and I found that the original bubble sort algorithm is so inefficient, so I wrote a ...
3
votes
1
answer
19k
views
Split a file into multiple files if it reaches a particular limit?
For each clientId, I have a Collection<Task> object. I am making file for each clientId...
3
votes
2
answers
212
views
Generating a string in a particular format by reading data from a map
I have a processToTaskIdHolder Map which contains processId as the key and taskId as the ...
4
votes
0
answers
221
views
Algorithm to find connected tiles (percolation)
I wrote a little program in JavaFX which displays a path of neighbouring open tiles going from top to bottom. It should simulate a percolation.
The algorithm iterates through the whole grid (every ...
1
vote
2
answers
271
views
"Disease Spread" challenge
Right now I'm solving this problem on codewars.com. I'm not sure about how to optimise the code further. Or is my algorithm inefficient? If it's an algorithmic issue, could someone help me how to go ...
4
votes
1
answer
574
views
Add 1 to an integer represented as an array of digits
Problem Statement
This is another LeetCode question I came across, where I need to add 1 to a number.
The number is represented as an integer array where each index position is a digit and ...
1
vote
1
answer
110
views
Return the largest product of 2 numbers that is a multiple of 9 in O(n)
Given an array of integers, I have to return the largest product of any 2 numbers, and that product has to be a multiple of 9.
...
1
vote
1
answer
53
views
Efficiently determine whether two arbitrarily-sized integers share a digit
My current algorithm creates two new integers initialized to 0 (one for each input), then sets the nth bit to 1 if the integer's corresponding input contains the digit n. The bitwise AND of these ...
3
votes
4
answers
12k
views
Most frequent word in an array of strings - Java
Input word array is
...
6
votes
2
answers
684
views
Java algorithm to declutter rectangles
I've been working on an algorithm to declutter rectangles while keeping them as close as possible to their original location (and oriented the same way). It seems to work fine when I have less than 1,...
4
votes
1
answer
3k
views
Given a String and dictionary of words, break the string in minimum space sentence
Given a String and dictionary of words, break the string in minimum space sentence.
...