JinFei's Blog

Thinking will not overcome fear but action will.

[剑指Offer]二叉树的下一个节点

二叉树的遍历

题目描述 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。 解题思路 分为三种情况(三种情况是顺序判断的) 二叉树为空,则返回空; 节点右孩子存在,则设置一个指针从该节点的右孩子出发,一直沿着指向左子结点的指针找到的叶子节点即为下一个节点; 节点不是根节点。如果该节点是其父节点的左...

[LeetCode]Qemu安装以及网络配置相关部分

网络配置,虚拟机,桥接

qemu安装以及网络配置相关部分 qemu相关介绍 qemu是什么,简单来说它是一个虚拟机的管理器,类似Virtualbox之类的。为了使虚机达到接近主机的性能,一般会结合kvm(或者Xen)对硬件虚拟化。kvm负责cpu+memory虚拟化,但kvm不能模拟其他设备;qemu负责模拟IO设备(网卡,usb等),两者结合能实现真正意义上的全系统仿真。 QEMU模拟器基本原理 作为系统模拟...

[LeetCode]395. Longest Substring with At Least K Repeating Characters

求至少出现k次的子字符串

题目描述 Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times. Example1: Input: s...

[LeetCode]289. Game of Life

遍历,状态的转换

题目描述 According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.” Given a bo...

[LeetCode]341. Flatten Nested List Iterator

自定义list的迭代器

题目描述 Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list – whose elements may also be integers or other lists. Example1: ...

[LeetCode]116. Populating Next Right Pointers in Each Node

树的层次遍历,递归,非递归

题目描述 You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; ...

[LeetCode]150. Evaluate Reverse Polish Notation

栈的应用,四则运算

题目描述 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. NOTE Division betw...

[LeetCode]127. Word Ladder

dp,字母的组合

题目描述 Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that: Only one letter can be chang...

[LeetCode]73. Set Matrix Zeroes

将二维数组清除整行整列

题目描述 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: ...

[LeetCode]54. Spiral Matrix

旋转打印矩阵

题目描述 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example1: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ...