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

Related Articles

  1. Daily Interview Problem: Reverse Integer
  2. Algorithm Interview Question: Nth Fibonacci Number
  3. Daily Interview Problem: Validate Binary Search Tree
  4. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
  5. Two-Sum
  6. Algorithm Interview: No Adjacent Repeating Characters
  7. Daily Interview Problem: Find the k-th Largest Element in a List
  8. [Daily Problem] Remove k-th Last Element From Linked List
  9. Autorun.inf Virus Protection
  10. Daily Interview Problem: Group Words that are Anagrams

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