[Leetcode] Word Search I&II 二维字符矩阵查找单词

2016-06-13
阅读 7 分钟
4.6k
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same >letter cell may not be used more than once. For example, Given board = {...

[基本算法] Detect Cycle in Directed/Undirected Graph 有向图/无向图找环

2016-06-11
阅读 6 分钟
13.3k
Given n nodes labeled from 0 to n - 1 and a list of directed edges (each edge is a pair of nodes), write a function to check whether the graph contains a cycle. if edges = [0, 1], [1, 2], [0, 2]], it means 0 -> 1, 1 ->2, 0 -> 2. edges[i is parent, edgesi is child. For example: Given n = ...

[Leetcode] Graph Valid Tree 判断一个图是否为树

2016-06-11
阅读 4 分钟
11.5k
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. For example: Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true. Given n = 5 and edges = [[0, 1], [1, 2], [2,...

[Leetcode] Max Points on a Line 直线上最多的点数

2016-06-08
阅读 3 分钟
9.6k
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

[Leetcode] Palindrome Number 回文数

2016-06-07
阅读 2 分钟
2.5k
Determine whether an integer is a palindrome. Do this without extra space.

[Leetcode] Basic Calculator/Evaluate Expression 设计计算器/中缀表达式求值

2016-06-06
阅读 6 分钟
5.6k
Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should truncate toward zero. You may assume that the given expression is always valid. Some examples: "3+2*2...