上一页 1 ··· 4 5 6 7 8
摘要: Valid Anagram Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t = "nagaram" Output 阅读全文
posted @ 2018-07-04 21:21 Lin.B 阅读(119) 评论(0) 推荐(0) 编辑
摘要: In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Th 阅读全文
posted @ 2018-07-04 16:15 Lin.B 阅读(119) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2018-07-03 22:02 Lin.B 阅读(101) 评论(0) 推荐(0) 编辑
摘要: There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every 阅读全文
posted @ 2018-07-03 17:28 Lin.B 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 1、Path Sum 题目: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals t 阅读全文
posted @ 2018-06-24 22:22 Lin.B 阅读(318) 评论(0) 推荐(1) 编辑
摘要: 本次学习主要参考算法竞赛入门经典(第二版)。因为DFS本质上还是属于暴力破解,因此从基础的暴力求解法例题学起 1、生成1~n的排列 例如n=3时,输出(1,2,3)(1,3,2)(2,1,3)(2,3,1)(3,1,2)(3,2,1)。 尝试用递归的思想解决,先输出所有以1开头的排列,然后输出以2开 阅读全文
posted @ 2018-06-22 16:41 Lin.B 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 1、前言 学习数据结构的时候就已经了解了DFS原理,但是一直没有详细的复习和代码实现。再刷题的过程中发现很多题目都使用DFS,因此回头再好好梳理一下DFS的思路以及代码实现。 2、算法理论 2.1 理论知识 深度优先搜索算法(英语:Depth-First-Search,简称DFS)是一种用于遍历或搜 阅读全文
posted @ 2018-06-20 11:37 Lin.B 阅读(207) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8