All Questions
146 questions
4
votes
1
answer
107
views
Efficient way to win points in chocolate bowl game
I'm working on an optimization problem involving a turn-based chocolate-sharing game, and I need help optimizing my current brute-force solution.
Problem Description:
You and your friend take turns ...
3
votes
1
answer
238
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 ...
9
votes
2
answers
628
views
Advent of code 2023 day 5 in Java: mapping integer ranges to new integer ranges
Context
I'll be passing an interview coding test in java soon. I am experienced with other programming languages but am very unfamiliar with Java. I am looking for critiques of the coding style much ...
6
votes
3
answers
498
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
535
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 ...
3
votes
1
answer
153
views
Find potentional sponsor for every animal
This is a programming challenge in Czeck. My translation follows.
Does anyone know what the time complexity of my code is?
Input: The first line contains 2 integers: the number of animals 1 ≤N ≤100 ...
1
vote
2
answers
699
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 ...
2
votes
2
answers
748
views
Print all combinations from dictionary which will result in number N
Print all combinations from dictionary which will result in the number N
...
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 ...
4
votes
1
answer
363
views
LeetCode 839: Similar String Groups II
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) ...
11
votes
6
answers
19k
views
Enhanced Hashmap - Add a number to all keys/values
I had the below problem in a coding test and I got 28/30 tests passes and 2 failed due to a time-out.
Problem You have created a programming language and now you have decided to add ...
3
votes
1
answer
287
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....
2
votes
0
answers
813
views
LeetCode 218: The Skyline Problem II
Here I'm posting my Java code for the skyline problem. If you have time and would like to review, please do so, I'd appreciate that.
Problem
A city's skyline is the outer contour of the silhouette ...
3
votes
1
answer
475
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 ...