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

Related Articles

  1. Daily Interview Problem: Word Ordering in a Different Alphabetical Order
  2. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  3. Floor and Ceiling of a Binary Search Tree
  4. Longest Substring Without Repeating Characters
  5. Daily Interview Problem: Trapping Rainwater
  6. Daily Interview Problem: Arithmetic Binary Tree
  7. Daily Interview Problem: Decode String
  8. Algorithm Interview: Maximum Path Sum in Binary Tree
  9. Sorting a list with 3 unique numbers
  10. Fix Brackets

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" />