All Questions
275 questions
6
votes
3
answers
465
views
Leetcode: Largest Number
I was trying out leetcode's Largest Number.
As per the challenge's description:
Given a list of non-negative integers nums, arrange them such that
they form the largest number and return it. Since ...
1
vote
3
answers
142
views
Maximum Sum BST in a Binary Tree
I was trying to find the Maximum sum BST of a binary tree on LeetCode. While the Java code I have come up with, mostly seems right and is able to pass 55 out of the given 59 test cases too, the error ...
2
votes
1
answer
94
views
Semi-dynamic range minimum query (RMQ) tree in Java
Introduction
I have this semi-dynamic range minimum query (RMQ) tree in Java. It is called semi-dynamic due to the fact that it cannot be modified after it is constructed. However, the values ...
3
votes
2
answers
401
views
Implementation of a market that matches bids to offers
This is my task:
Each line in the file can be one of the following:
Updates to the limit order book in the following format:
...
2
votes
1
answer
757
views
Traverse a list of tree nodes
I am wondering if there is a better way to traverse a list of trees.
Here is my current algorithm:
Collect the parent IDs in a Map
Traverse all the groups and find ones where their ID is not in the ...
1
vote
1
answer
87
views
Java - Select the maximum integers from sliding windows over an array
So I have the following algorithm. Given an array A[0 ... n - 1] and the window length w, compute all the windows ...
3
votes
0
answers
345
views
Simple Merkle Tree
Discussion
I just started learning about Merkle Trees and wanted to get some practice by attempting to implement a very simple Merkle Tree.
The constructor for the tree takes some type of hash ...
1
vote
1
answer
67
views
Comparing two general LCA algorithms in Java
Now I have two algorithms solving a problem: given a general (multi-way) tree, and any array of node names, find the the node that is the deepest common ancestor.
...
1
vote
1
answer
217
views
Comparing a prefix tree against a HashSet of strings in Java
Here, I have made an attempt to find out whether a prefix tree is any more efficient than a simple java.util.HashSet<String>. See what I have:
...
0
votes
1
answer
56
views
is my Prim's MST implementation terse enough?
I did research because I want to learn Kruskal's and Prim's MSTs. I did research and after a solid understanding, I went to my textbook and got their libraries:
https://algs4.cs.princeton.edu/code/...
3
votes
1
answer
109
views
Building a tree containing all permutations of arithmetic expressions given some numbers
Given any series of numbers, for example 1,2,3,4,5 and given the arithmetic operands + - * / including parenthesis, what would be the most optimal way to build a tree that contains all permutations ...
2
votes
1
answer
107
views
Pretty print a tree from minimal data input
I'm currently working on an uncrafting tool for minecraft and got a neat output working that shows all the materials needed in a tree. I wonder if the code used to print that tree could be improved ...
2
votes
1
answer
106
views
Find Invalid User Relationships in User to Manager Map (validate map as valid tree structure with no circular relationships)
We have a new service where an admin can upload a spreadsheet of new users they want to add to our application. During our processing we make a union map of all the users both existing and new ...
2
votes
1
answer
373
views
Sum of all Paths in Binary Tree
Problem
For the given binary tree return the list which has sum of every paths in a tree. i.e Every path from root to leaf.
I've written following solution.
...
1
vote
1
answer
118
views
Data mining in Java: finding undrawn lottery rows - follow-up
(See the previous (initial) iteration.)
This time, I have substantially reduced the usage of the final and this keywords. Also, ...