Graphs

Categories: Code Problem / Data Structures and Algorithms / Recursion (32) Code Problem / Data Structures and Algorithms / Binary Search (30) Code Problem / Data Structures and Algorithms / Linked Lists (26) Code Problem / Data Structures and Algorithms / Backtracking (26) Code Problem / Data Structures and Algorithms / Stacks and Queues (25) Code Problem / Data Structures and Algorithms / Hashing (24) Databases / SQL / Backup and Recovery (19) Code Problem / Data Structures and Algorithms / Arrays and Strings (19) Databases / SQL / Database Normalization (18) Code Problem / Data Structures and Algorithms / Time Complexity (17) Databases / SQL / Locking (16) Databases / SQL / Replication (15) Databases / SQL / SQL Queries (13) Code Problem / Data Structures and Algorithms / Graphs (13) Databases / SQL / Database Security (13)  More...

Recent solutions:

Check these solutions from our community:
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This technical problem deals with finding a route between two nodes in a directed graph. An example input is given, as well as the desired output.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate has correctly implemented a breadth-first search algorithm to find whether there is a route between two nodes in a directed graph.
Dec 11
Code Problem / Data Structures and Algorithms DifficultyMedium C++
The problem asks for a way to determine whether there is a route between two nodes in a directed graph. One example is given, where the nodes are connected in a linear fashion. The solution should work for more general cases as well.
About this solution: The candidate's solution is complete and solves the problem. The candidate has used a breadth-first search approach, which is a good choice for this problem.
Dec 08
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem asks for the shortest route between two nodes in a graph. The input is a list of nodes and their connections. The output should be the shortest route between the two given nodes.
About this solution: The candidate's solution correctly implements a breadth-first search to find a route between two nodes in a graph. The solution is complete and correctly handles edge cases such as null input values.
Dec 07
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem asks us to find the shortest path between any two words in a list. For example, given the list ["cat", "bat", "rat"], the shortest path would be " cat" -> "bat" -> "rat".
About this solution: The candidate's solution does not demonstrate a level of completeness and does not solve the problem. The general approach is not clear.
Dec 02
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This technical problem involves determining whether a route exists between two nodes in a directed graph. An example input and output are given.
About this solution: The candidate's solution is correct and uses a breadth-first search to find the shortest path between two nodes. The time complexity is O(n) and the space complexity is O(n).
Dec 01
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem is about finding the shortest path through a maze. The input is a 2D array representing the maze, and the output is the shortest path from the top-left corner to the bottom-right corner.
About this solution: The candidate's solution correctly solves the problem and demonstrates a level of completeness. The candidate uses a breadth-first search algorithm to find the shortest path through the maze. The time and space complexity of the algorithm is correctly analyzed.
Nov 30
Code Problem / Data Structures and Algorithms DifficultyMedium C++
The shortest path between two nodes in an undirected graph can be found by traversing the graph from one node to the other.
About this solution: The candidate's solution is complete and solves the problem. The candidate uses a breadth-first search approach to find the shortest path between two nodes.
Nov 29
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This function takes in a graph represented as an adjacency list, and returns whether or not the graph contains a cycle.
About this solution: The candidate's solution is correct and demonstrates a good understanding of depth first search. However, the code could be more concise. For example, the has_cycle function could be written as follows: def has_cycle(g): visited = set() for node in g: if node not in visited: if dfs(node, visited, None): return 1 return 0 def dfs(node, visited, parent): visited.add(node) for neighbor in node: if neighbor not in visited: if dfs(neighbor, visited, node): return True elif neighbor != parent: return True return False
Nov 27