All Questions
168 questions
4
votes
3
answers
288
views
Given two sparse vectors, compute their dot product
Problem Statement:
Given two sparse vectors, compute their dot product.
Implement class SparseVector:
SparseVector(nums) Initializes the object with the vector nums
dotProduct(vec) Compute the dot ...
6
votes
3
answers
712
views
Program that brute forces to find the minimum dominating set
This program solves the minimum dominating set but it takes an insanely long time to run. In case you do not know, in graph theory, a dominating set for a graph G is a subset D of its vertices, such ...
4
votes
2
answers
429
views
Map constructor utility class in Java 8
In a Java 8 project, I'm using several maps, many of which contain static or default content. In Java 9 and newer, there's the convenient Map.of() method and I want ...
5
votes
1
answer
167
views
Set implementation
I believe reinventing the wheel is in fact a good learning exercise. How can I improve my Set implementation without just copying ...
5
votes
1
answer
917
views
Merge multiple map with java stream api
I am trying to merge multiple map with Java stream API.
The reqiurements like ...
this method can receive multiple map, does not care hot many of it
support 2 merge method: intersection, union
if key ...
1
vote
3
answers
187
views
Caesar cipher - Encode text from external file using HashMap Java
This is one of my school assignments and I just wanted to ask if there are some obvious mistakes or things I could maybe improve in this code.
Thank you for any suggestions.
...
0
votes
1
answer
151
views
LeetCode - LRU Cache by rodde
I have solved this LeetCode problem. Depending (perhaps) on the server load, I once scored the following performance figures:
My code follows:
...
1
vote
2
answers
439
views
4
votes
1
answer
186
views
Langton's Ant cellular automaton in Java
I made a couple of little games and cellular automata in Java. For every new 'game', I used the same code as a base, except for the game logic of course. With every iteration of me customizing my ...
1
vote
1
answer
440
views
Simple Hash Ring Implementation
Introduction
I have been reading about Consistent Hashing and in an attempt to better understand the concept, I wanted to implement a simple hash ring.
I did not implement the concept of virtual nodes ...
0
votes
1
answer
496
views
Find sets of anagrams in a string array
Below is a program where in which I find groupings of anagrams in a given string array. Is there a better way to do it?
...
1
vote
1
answer
764
views
Proper way to transform nested lists to nested maps [closed]
I want to transform a list of lists of lists that I have in a MongoDB document into a map of maps of maps in my java Domain class.
The problem I have is that the fields are mixed between the levels. ...
1
vote
1
answer
2k
views
Finding nodes with 0 or 1 parents - DFS or BFS
I completed the following question but it seems a lot of space complexity.
Do you think is there a way to complete it with graph search or so?
Thanks for the comments.
Suppose we have some input data ...
6
votes
1
answer
1k
views
friend locator app
I was rejected after a tech screening for the following code.
I mainly struggled to make the code 'production ready'.
I was running out of time so I did not create a class for testing.
How could I ...
2
votes
1
answer
91
views
Sports DataSheet
This program asks the user for a players name, # of goals, saves, games played, etc. This information is ten organized on a .txt file along with the time the information was logged. users can also ...