All Questions
Tagged with graph programming-challenge
52 questions
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 ...
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 ...
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
...
-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 ...
-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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
...
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 ...
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 ...
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 ...
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:...