To the Top
File:  root - text - article - 2019 - 10 - find-cycles-in-a-graph.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 330 Views, 18621 Search Bots | 72 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Facebook:

Given an undirected graph, determine if a cycle exists in the graph.

Here is a function signature:


def find_cycle(graph):
# Fill this in.

graph = {
'a': {'a2':{}, 'a3':{} },
'b': {'b2':{}},
'c': {}
}
print find_cycle(graph)
# False
graph['c'] = graph
print find_cycle(graph)
# True


Can you solve this in linear time, linear space?
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Cateogry: Computing | 330 Views, 18621 Search Bots | 72 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Question: Longest Sequence with Two Unique Numbers
  2. Algorithm Interview Question: H-Index
  3. A trick for getting good at coding interviews FASTER
  4. Algorithm Interview Question: Max and Min with Limited Comparisons
  5. [Daily Problem] Remove k-th Last Element From Linked List
  6. Spectrum Master
  7. [Daily Problem] Remove Consecutive Nodes that Sum to 0
  8. Absolute Path
  9. Non-decreasing Array with Single Modification
  10. Delphi Dynamic Array

Comments (0)

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">