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 | 343 Views, 19392 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 | 343 Views, 19392 Search Bots | 72 Words Subscribe to Feed Burner

Related Articles

  1. Progess made
  2. Daily Interview Problem: Longest Substring With K Distinct Characters
  3. Batch Programming in XP
  4. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  5. [Daily Problem] Angles of a Clock
  6. Daily Interview Problem: Trapping Rainwater
  7. Daily Interview Problem: Find the Number of Islands
  8. Fix Brackets
  9. Daily Interview Problem: Count Number of Unival Subtrees
  10. Daily Interview Problem: Merge List Of Number Into Ranges

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />