All Questions
224 questions
4
votes
4
answers
444
views
Finding Special Parts in a Word
Task description:
Imagine you have a long word made up of small letters like "a", "b", "c", ancd so on. Let’s call this word a puzzle word.
We want to look at all the ...
3
votes
1
answer
237
views
Leetcode: Number of Islands - BFS (Queue vs Recursion)
I was playing around with leetcode's Number of Islands.
As per the challenge's description:
Given an m x n 2D binary grid grid which represents a map of '1's
(land) and '0's (water), return the ...
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 ...
4
votes
2
answers
513
views
Leetcode: Steps to Make Array Non-decreasing
I was trying out leetcode's Steps to Make Array Non-decreasing
As per the challenge's description:
You are given a 0-indexed integer array nums. In one step, remove all
elements nums[i] where nums[i ...
9
votes
4
answers
2k
views
Leetcode : First Missing Positive
I was trying out leetcode's first missing positive.
As per the challenge's description:
Given an unsorted integer array nums, return the smallest missing
positive integer.
You must implement an ...
1
vote
0
answers
80
views
A parallel MSD radix sort in Java for integer keys
I have this repository: https://github.com/coderodde/ParallelRadixSort.java/tree/main
It contains a parallel MSD radix sort presented below:
...
4
votes
2
answers
691
views
Merge a list of deeply nested HashMaps
Suppose I have a list of hashmaps (<String, Object>). Values can be either scalar types or a nested HashMap with the same type.
I need to merge a list of this ...
1
vote
0
answers
138
views
Making Robert Tarjan's offline LCA algorithm run (much) faster (Java)
I have produced this GitHub repository that compares the performance of:
Robert Tarjan's off-line lowest common ancestors algorithm,
An improvement of the above algorithm.
Typical demo program ...
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 ...
5
votes
4
answers
571
views
Fastest function to find cumulative largest perfect squares of a single number?
I'm attempting to write an algorithm that will find the largest perfect squares of a given integer, subtracting their values from the total each time, as fast as possible. It's somewhat hard to ...
0
votes
3
answers
1k
views
Calculate square of (sum of even-indexed) - (sum of odd-indexed) subarrays from an array
Find all subarrays from a given array in the least possible time complexity.
Requirement:
calculate the square of (sum of even-indexed elements) - (the sum of odd-indexed elements) of al the subarrays....
1
vote
2
answers
646
views
Leetcode kth largest element without using heaps
I was working on kth largest element problem on leetcode
Question
Given an integer array nums and an integer k, return the kth largest element in the array.
Note that it is the kth largest element in ...
1
vote
1
answer
90
views
return the number of times is state of bulb changed?
Today in an exam I faced a problem which is Toggled Switches(Hacker Earth) as it is an exam question So, I am unable to send the question or its link (exactly).
Problem: we have to print a number ...
2
votes
1
answer
71
views
Distribute items based on the time duration
I just finished a small assignment and I would like to get some feedback about the implementation here. Basically, it was all about distributing items ("talks" in this case) throughout the ...
3
votes
1
answer
280
views
LeetCode 146: LRU Cache III
I'm posting my Java code for LeetCode's LRU Cache. If you have time and would like to review, please do so. Thank you!
Problem
Design and implement a data structure for Least Recently Used (LRU) cache....