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

Related Articles

  1. Daily Interview Problem: Queue Using Two Stacks
  2. Invert a Binary Tree
  3. Reverse a Linked List
  4. Daily Interview Problem: Find the Number of Islands
  5. Longest Substring Without Repeating Characters
  6. First and Last Indices of an Element in a Sorted Array
  7. Daily Interview Problem: First Missing Positive Integer
  8. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  9. Daily Interview Problem: Count Number of Unival Subtrees
  10. [Daily Problem] Validate Balanced Parentheses

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    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="noindex, follow" />