
Graph
文章平均质量分 84
iyangdi
这个作者很懒,什么都没留下…
展开
-
Google算法题:仓鼠血缘
题目如何找到两只仓鼠的血缘关系。没有预定义任何数据结构,只是让你写一个函数来做。有能力对问题进行建模,然后快速而高质量地编码分析(1)构造血缘图(2)运用dfs,看能不能找到从仓鼠a到仓鼠b的路径,有则说明有血缘,无则说明无血缘代码package com.graph;import java.util.*;public cl原创 2017-08-07 22:23:50 · 723 阅读 · 0 评论 -
LeetCode Graph:M210. Course Schedule II
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a原创 2017-08-05 09:07:46 · 230 阅读 · 0 评论 -
LeetCode Graph:M310. Minimum Height Trees
For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini原创 2017-08-05 10:36:09 · 262 阅读 · 0 评论 -
LeetCode Graph:M207_Course_Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as原创 2017-08-04 22:27:34 · 224 阅读 · 0 评论 -
LeetCode Graph:M332. Reconstruct Itinerary
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus原创 2017-08-05 15:47:13 · 261 阅读 · 0 评论 -
LeetCode Graph:M399. Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answ原创 2017-08-05 18:50:10 · 304 阅读 · 0 评论 -
LeetCode Graph:M133_Clone_Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each原创 2017-08-04 22:38:53 · 215 阅读 · 0 评论 -
LeetCode:M59. Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [原创 2017-08-05 19:27:02 · 231 阅读 · 0 评论