Skip to main content

All Questions

Filter by
Sorted by
Tagged with
3 votes
0 answers
152 views

Advent of Code 2021 Day 19

I am taking advantage of the recent layoffs to teach myself Kotlin. I am a career Java programmer, I've touched Kotlin before but not actively, and not for a few years. I wrote it all in one file ...
durron597's user avatar
  • 948
1 vote
1 answer
534 views

Cheapest flights within k stops algorithm in JavaScript

The problem: There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is ...
myTest532 myTest532's user avatar
4 votes
1 answer
220 views

Python leetcode: scheduling courses to meet prerequisite requirements

This is my solution to Leetcode #210, Course Schedule II. There are a total of numCourses courses you have to take, labeled from ...
gust's user avatar
  • 375
-2 votes
1 answer
825 views

HackerRank | Roads and Libraries - Code Optimization

Major Edit: I wish people threw in a comment regarding what they are expecting instead of downvoting this question. I am quite appreciative of constructive feedback. I know it is only 3 people out of ...
desert_ranger's user avatar
-2 votes
1 answer
153 views

How to work in linear time with DFS

I tried a Hackerrank problem and it gives me a successful message, it works fine for Hackerrank criteria. The member states of the UN are planning to send 2 people to the moon. They want them to be ...
rusiru thushara's user avatar
3 votes
1 answer
126 views

LeetCode: Network Delay Time Bellman Ford C#

https://leetcode.com/problems/network-delay-time/ There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source ...
Gilad's user avatar
  • 5,373
3 votes
2 answers
2k views

LeetCode: Longest String Chain (Java)

For the question, I had a pretty messy solution so I would like some advice on how to better use Java to make the code a bit cleaner. Also, a semi-hack that I did that I'm not proud of is checking if ...
togepi's user avatar
  • 85
5 votes
2 answers
4k views

HackerRank: Friend Circles (DFS in Java)

I got this problem on a HackerRank challenge and this was the best I could come up with. It's basically just using DFS to find connected components (in this case, friend circles). I was having a tough ...
togepi's user avatar
  • 85
6 votes
1 answer
186 views

City Construction Solution times out for large input

Problem The country of Hackerland has n cities connected by m uni-directional roads. The cities are numbered from ...
Anatolii's user avatar
  • 992
1 vote
0 answers
312 views

Graph-coloring solution using depth-first search

I'm trying to solve this question: Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of n squares ...
nz_21's user avatar
  • 1,051
3 votes
2 answers
2k views

Geektrust: Modelling Family Relationships in a OO way

I'm trying to model family relationships in a OO way, i.e. As we update the relationships between two individuals our model must be able to find the people given a person and the type of relationship ...
thebenman's user avatar
  • 1,178
3 votes
1 answer
320 views

Find number of islands Leetcode

Here is the question: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally ...
Mosbius8's user avatar
  • 787
7 votes
1 answer
941 views

Hackerrank: Computer Game (max-flow problem with integer factorization)

I am working on a coding challenge from the Hackerrank site. Given two equal-length arrays of integers, with values from 2 to 109, find the maximum number of times we can remove a pair (Ai, Bj) where ...
bmk's user avatar
  • 181
2 votes
1 answer
545 views

Leetcode online Find the judge, graph with highest degree

Here is the problem. In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town ...
Mosbius8's user avatar
  • 787
4 votes
0 answers
504 views

Two solutions to leetcode 127.wordLadder

I am working on Word Ladder - LeetCode Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:...
Alice's user avatar
  • 605

15 30 50 per page