当前位置: 首页 > 编程日记 > 正文

数据结构与算法:16 Leetcode同步练习(六)

Leetcode同步练习(六)

目录

  • 题目01:相同的树
  • 题目02:对称二叉树
  • 题目03:二叉树的最大深度
  • 题目04: Pow(x, n)
  • 题目05:子集
  • 题目06:格雷编码
  • 题目07:二叉树的最近公共祖先
  • 题目08:二叉树的前序遍历
  • 题目09:二叉树的中序遍历
  • 题目10:二叉树的后序遍历

题目01:相同的树

  • 题号:100
  • 难度:简单
  • https://leetcode-cn.com/problems/same-tree/

给定两个二叉树,编写一个函数来检验它们是否相同。

如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。

示例 1:

输入:      1         1/ \       / \2   3     2   3[1,2,3],   [1,2,3]输出: true

示例 2:

输入:      1          1/           \2             2[1,2],     [1,null,2]输出: false

示例 3:

输入:      1         1/ \       / \2   1     1   2[1,2,1],   [1,1,2]输出: false

参考代码:

  • 执行结果:通过
  • 执行用时:160 ms, 在所有 C# 提交中击败了 5.85% 的用户
  • 内存消耗:24 MB, 在所有 C# 提交中击败了 6.67% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/public class Solution
{public bool IsSameTree(TreeNode p, TreeNode q){//递归终止条件if (p == null && q == null)return true;if (p != null && q != null && p.val == q.val){return IsSameTree(p.left, q.left)&& IsSameTree(p.right, q.right);}return false;}
}

题目02:对称二叉树

  • 题号:101
  • 难度:简单
  • https://leetcode-cn.com/problems/symmetric-tree/

给定一个二叉树,检查它是否是镜像对称的。

例如,二叉树 [1,2,2,3,4,4,3] 是对称的。

    1/ \2   2/ \ / \
3  4 4  3

但是下面这个 [1,2,2,null,3,null,3] 则不是镜像对称的:

    1/ \2   2\   \3    3

参考代码:

第一种:采用递归的方法

  • 执行结果:通过
  • 执行用时:132 ms, 在所有 C# 提交中击败了 16.67% 的用户
  • 内存消耗:25.1 MB, 在所有 C# 提交中击败了 5.17% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*///镜像对称的递归函数
public class Solution
{public bool IsSymmetric(TreeNode root){return IsMirror(root, root);}private bool IsMirror(TreeNode t1, TreeNode t2){if (t1 == null && t2 == null) return true;if (t1 == null || t2 == null) return false;return (t1.val == t2.val)&& IsMirror(t1.left, t2.right)&& IsMirror(t1.right, t2.left);}
}

第二种:采用队列的方法

思路:利用二叉树的层次遍历的方式来实现。

  • 执行结果:通过
  • 执行用时:112 ms, 在所有 C# 提交中击败了 70.93% 的用户
  • 内存消耗:24.9 MB, 在所有 C# 提交中击败了 5.17% 的用户
public class Solution
{public bool IsSymmetric(TreeNode root){if (root == null)return true;Queue<TreeNode> nodes = new Queue<TreeNode>();nodes.Enqueue(root.left);nodes.Enqueue(root.right);while (nodes.Count != 0){TreeNode node1 = nodes.Dequeue();TreeNode node2 = nodes.Dequeue();if (node1 == null && node2 == null)continue;if (node1 == null || node2 == null)return false;if (node1.val != node2.val)return false;nodes.Enqueue(node1.left);nodes.Enqueue(node2.right);nodes.Enqueue(node1.right);nodes.Enqueue(node2.left);}return true;}
}

题目03:二叉树的最大深度

  • 题号:104
  • 难度:简单
  • https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/

给定一个二叉树,找出其最大深度。

二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。

说明: 叶子节点是指没有子节点的节点。

示例

给定二叉树 [3,9,20,null,null,15,7]

    3/ \9  20/  \15   7

返回它的最大深度 3 。

参考代码:

第一种:利用队列实现层次遍历的思路

  • 执行结果:通过
  • 执行用时:108 ms, 在所有 C# 提交中击败了 88.13% 的用户
  • 内存消耗:25.5 MB, 在所有 C# 提交中击败了 5.97% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public int MaxDepth(TreeNode root){if (root == null)return 0;Queue<TreeNode> q = new Queue<TreeNode>();int deep = 0;q.Enqueue(root);while (q.Count != 0){deep++;int count = 0;int size = q.Count;while (count < size){TreeNode node = q.Dequeue();count++;if (node.left != null)q.Enqueue(node.left);if (node.right != null)q.Enqueue(node.right);}}return deep;}
}

第二种:利用递归

思路:递归分别求左右子树的最大深度,并加到原有层数上,最后返回两者中的最大值。

  • 执行结果:通过
  • 执行用时:132 ms, 在所有 C# 提交中击败了 16.62% 的用户
  • 内存消耗:25.5 MB, 在所有 C# 提交中击败了 6.06% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public int MaxDepth(TreeNode root){if (root == null)return 0;int llen = 1;int rlen = 1;if (root.left != null){llen += MaxDepth(root.left);}if (root.right != null){rlen += MaxDepth(root.right);}return llen > rlen ? llen : rlen;}
}

题目04: Pow(x, n)

  • 题号:50
  • 难度:中等
  • https://leetcode-cn.com/problems/powx-n/

实现 pow(x, n) ,即计算 x 的 n 次幂函数。

示例 1:

输入: 2.00000, 10
输出: 1024.00000

示例 2:

输入: 2.10000, 3
输出: 9.26100

示例 3:

输入: 2.00000, -2
输出: 0.25000
解释: 2-2 = 1/22 = 1/4 = 0.25

示例 4:

输入: 1.00000, -2147483648
输出: 1.00000

说明:

  • -100.0 < x < 100.0
  • n 是 32 位有符号整数,其数值范围是 [−2^31, 2^31 − 1] 。

思路:利用快速幂法。

假设我们要求a^b,那么b可以拆成二进制表示,例如当b = 5时,5的二进制是0101,5 = 2^3×0 + 2^2×1 + 2^1×0 + 2^0×1,因此,我们将a^5转化为算 a^(2^3×0 + 2^2×1 + 2^1×0 + 2^0×1),即a^(2^0) × a^(2^2)

我们先算出所有2的幂,然后在算出所有x的2的幂次方。再把n拆成二进制,把二进制当中对应位置是1的值乘起来,就得到了结果。这套方法称为 快速幂法

参考代码

  • 执行结果:通过
  • 执行用时:56 ms, 在所有 C# 提交中击败了 51.87% 的用户
  • 内存消耗:15.1 MB, 在所有 C# 提交中击败了 50.00% 的用户
public class Solution
{public double MyPow(double x, int n){int neg = n < 0 ? -1 : 1;long g = Math.Abs((long)n);double[] d = new double[32];d[0] = x;for (int i = 1; i < 32; i++){d[i] = d[i - 1] * d[i - 1];}double result = 1.0d;for (int i = 0; i < 32; i++){int mask = 1 << i;if ((mask & g) != 0){result *= d[i];}}return neg != -1 ? result : 1.0 / result;}
}

题目05:子集

  • 题号:78
  • 难度:中等
  • https://leetcode-cn.com/problems/subsets/

给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集)。

说明:解集不能包含重复的子集。

示例:

输入: nums = [1,2,3]
输出:
[[3],[1],[2],[1,2,3],[1,3],[2,3],[1,2],[]
]

参考代码

第一种:回溯法

依次以nums[i]为启始点进行搜索,且后续搜索数值都要大于前一个数值,这样会避免重复搜索。

回溯过程

  • 状态:通过
  • 行用时: 356 ms, 在所有 C# 提交中击败了 92.31% 的用户
  • 内存消耗: 29.2 MB, 在所有 C# 提交中击败了 6.67% 的用户
public class Solution
{private IList<IList<int>> _result;public IList<IList<int>> Subsets(int[] nums){_result = new List<IList<int>>();int len = nums.Length;if (len == 0){return _result;}IList<int> item = new List<int>();Find(nums, 0, item);return _result;}private void Find(int[] nums, int begin, IList<int> item){// 注意:这里要 new 一下_result.Add(new List<int>(item)); if (begin == nums.Length)return;for (int i = begin; i < nums.Length; i++){item.Add(nums[i]);Find(nums, i + 1, item);// 组合问题,状态在递归完成后要重置item.RemoveAt(item.Count - 1); }}
}

第二种:子集扩展法

  • 状态:通过
  • 执行用时: 352 ms, 在所有 C# 提交中击败了 94.51% 的用户
  • 内存消耗: 29.2 MB, 在所有 C# 提交中击败了 6.67% 的用户
public class Solution
{public IList<IList<int>> Subsets(int[] nums){IList<IList<int>> result = new List<IList<int>>();IList<int> item = new List<int>();result.Add(item);for (int i = 0; i < nums.Length; i++){for (int j = 0, len = result.Count; j < len; j++){item = new List<int>(result[j]);item.Add(nums[i]);result.Add(item);}}return result;}
}

第三种:位运算

思路: 利用整数集合的思路。

{1,2,3}为例,三个数,共2^3个子集。

000 -> []
100 -> [1]
101 -> [1,3]
110 -> [1,2]
111 -> [1,2,3]
...
  • 状态:通过
  • 执行用时: 348 ms, 在所有 C# 提交中击败了 97.80% 的用户
  • 内存消耗: 29.5 MB, 在所有 C# 提交中击败了 6.67% 的用户
public class Solution
{public IList<IList<int>> Subsets(int[] nums){IList<IList<int>> result = new List<IList<int>>();int count = nums.Length;for (int i = 0; i < 1 << count; i++){IList<int> item = new List<int>();for (int j = 0; j < count; j++){int mask = 1 << j;if ((mask & i) != 0)item.Add(nums[j]);}result.Add(item);}return result;}
}

题目06:格雷编码

  • 题号:89
  • 难度:中等
  • https://leetcode-cn.com/problems/gray-code/

格雷编码是一个二进制数字系统,在该系统中,两个连续的数值仅有一个位数的差异。

给定一个代表编码总位数的非负整数 n,打印其格雷编码序列。格雷编码序列必须以 0 开头。

示例 1:

输入: 2
输出: [0,1,3,2]
解释:
00 - 0
01 - 1
11 - 3
10 - 2对于给定的 n,其格雷编码序列并不唯一。
例如,[0,2,3,1] 也是一个有效的格雷编码序列。00 - 0
10 - 2
11 - 3
01 - 1

示例 2:

输入: 0
输出: [0]
解释: 我们定义格雷编码序列必须以 0 开头。给定编码总位数为 n 的格雷编码序列,其长度为 2^n。当 n = 0 时,长度为 2^0 = 1。因此,当 n = 0 时,其格雷编码序列为 [0]

思路

雷格码

由 n 位推导 n+1 位结果时,n+1 位结果包含 n 位结果,同时包含 n 位结果中在高位再增加一个位 1 所形成的令一半结果,但是这一半结果需要与前一半结果镜像排列。

参考代码

  • 状态:通过
  • 12 / 12 个通过测试用例
  • 执行用时: 296 ms, 在所有 C# 提交中击败了 95.83% 的用户
  • 内存消耗: 24.8 MB, 在所有 C# 提交中击败了 16.67% 的用户
public class Solution
{public IList<int> GrayCode(int n){IList<int> lst = new List<int>();lst.Add(0);for (int i = 1; i <= n; i++){for (int j = lst.Count - 1; j >= 0; j--){int item = lst[j] + (1 << i - 1);lst.Add(item);}}return lst;}
}

题目07:二叉树的最近公共祖先

  • 题号:236
  • 难度:中等
  • https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/

给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。

百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。”

例如,给定如下二叉树: root = [3,5,1,6,2,0,8,null,null,7,4]

示例 1:

输入: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
输出: 3
解释: 节点 5 和节点 1 的最近公共祖先是节点 3

示例 2:

输入: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
输出: 5
解释: 节点 5 和节点 4 的最近公共祖先是节点 5。因为根据定义最近公共祖先节点可以为节点本身。

说明:

  • 所有节点的值都是唯一的。
  • p、q 为不同节点且均存在于给定的二叉树中。

参考代码

思路:利用递归

  • 状态:通过
  • 执行用时: 132 ms, 在所有 C# 提交中击败了 96.10% 的用户
  • 内存消耗: 27.5 MB, 在所有 C# 提交中击败了 20.00% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/public class Solution
{public TreeNode LowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q){return Find(root, p, q);}private TreeNode Find(TreeNode current, TreeNode p, TreeNode q){if (current == null || current == p || current == q)return current;TreeNode left = Find(current.left, p, q);TreeNode right = Find(current.right, p, q);if (left != null && right != null)return current;return left != null ? left : right;}
}

题目08:二叉树的前序遍历

  • 题号:144
  • 难度:中等
  • https://leetcode-cn.com/problems/binary-tree-preorder-traversal/

给定一个二叉树,返回它的 前序遍历。

示例:

输入: [1,null,2,3]  1\2/3 输出: [1,2,3]

进阶: 递归算法很简单,你可以通过迭代算法完成吗?

参考代码

第一种:利用栈

  • 执行结果:通过
  • 执行用时:276 ms, 在所有 C# 提交中击败了 84.15% 的用户
  • 内存消耗:29.9 MB, 在所有 C# 提交中击败了 5.00% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public IList<int> PreorderTraversal(TreeNode root){IList<int> lst = new List<int>();Stack<TreeNode> stack = new Stack<TreeNode>();while (stack.Count != 0 || root != null){if (root != null){stack.Push(root);lst.Insert(lst.Count, root.val);root = root.left;}else{TreeNode node = stack.Pop();root = node.right;}}return lst;}
}

第二种:利用递归

  • 执行结果:通过
  • 执行用时:280 ms, 在所有 C# 提交中击败了 79.27% 的用户
  • 内存消耗:29.8 MB, 在所有 C# 提交中击败了 5.00% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public IList<int> PreorderTraversal(TreeNode root){IList<int> lst = new List<int>();PreOrder(root, lst);return lst;}private void PreOrder(TreeNode node, IList<int> lst){if (node == null)return;lst.Add(node.val);PreOrder(node.left, lst);PreOrder(node.right, lst);}
}

题目09:二叉树的中序遍历

  • 题号:94
  • 难度:中等
  • https://leetcode-cn.com/problems/binary-tree-inorder-traversal/

给定一个二叉树,返回它的中序 遍历。

示例:

输入: [1,null,2,3]1\2/3输出: [1,3,2]

进阶: 递归算法很简单,你可以通过迭代算法完成吗?

参考代码:

第一种:利用栈

  • 执行结果:通过
  • 执行用时:284 ms, 在所有 C# 提交中击败了 53.59% 的用户
  • 内存消耗:30 MB, 在所有 C# 提交中击败了 6.67% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public IList<int> InorderTraversal(TreeNode root){IList<int> lst = new List<int>();Stack<TreeNode> stack = new Stack<TreeNode>();while (stack.Count != 0 || root != null){if (root != null){stack.Push(root);root = root.left;}else{TreeNode node = stack.Pop();lst.Add(node.val);root = node.right;}}return lst;}
}

第二种:使用递归

  • 执行结果:通过
  • 执行用时:264 ms, 在所有 C# 提交中击败了 99.16% 的用户
  • 内存消耗:29.8 MB, 在所有 C# 提交中击败了 6.67% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public IList<int> InorderTraversal(TreeNode root){IList<int> lst = new List<int>();MidOrder(root, lst);return lst;}private void MidOrder(TreeNode node, IList<int> lst){if (node == null)return;MidOrder(node.left, lst);lst.Add(node.val);MidOrder(node.right, lst);}
}

题目10:二叉树的后序遍历

  • 题号:145
  • 难度:困难
  • https://leetcode-cn.com/problems/binary-tree-postorder-traversal/

给定一个二叉树,返回它的 后序 遍历。

示例:

输入: [1,null,2,3]  1\2/3 输出: [3,2,1]

进阶: 递归算法很简单,你可以通过迭代算法完成吗?

参考代码

第一种:利用栈

前序遍历顺序为:根 -> 左 -> 右

后序遍历顺序为:左 -> 右 -> 根

如果1:我们将前序遍历中节点插入结果链表尾部的逻辑,修改为将节点插入结果链表的头部

那么结果链表就变为了:右 -> 左 -> 根

如果2:我们将遍历的顺序由从左到右修改为从右到左,配合如果1

那么结果链表就变为了:左 -> 右 -> 根

这刚好是后序遍历的顺序

基于这两个思路,我们处理方式如下:

第一:修改前序遍历代码中,节点写入结果链表的代码,将插入队尾修改为插入队首

第二:修改前序遍历代码中,每次先查看左节点再查看右节点的逻辑,变为先查看右节点再查看左节点

  • 执行结果:通过
  • 执行用时:272 ms, 在所有 C# 提交中击败了 98.15% 的用户
  • 内存消耗:30 MB, 在所有 C# 提交中击败了 6.90% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public IList<int> PostorderTraversal(TreeNode root){IList<int> lst = new List<int>();Stack<TreeNode> stack = new Stack<TreeNode>();while (stack.Count != 0 || root != null){if (root != null){stack.Push(root);lst.Insert(0, root.val);root = root.right;}else{TreeNode node = stack.Pop();root = node.left;}}return lst;}
}

第二种:利用递归

  • 执行结果:通过
  • 执行用时:276 ms, 在所有 C# 提交中击败了 89.81% 的用户
  • 内存消耗:30 MB, 在所有 C# 提交中击败了 6.90% 的用户
/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int x) { val = x; }* }*/
public class Solution
{public IList<int> PostorderTraversal(TreeNode root){IList<int> lst = new List<int>();PostOrder(root, lst);return lst;}private void PostOrder(TreeNode node, IList<int> lst){if (node == null)return;PostOrder(node.left, lst);PostOrder(node.right, lst);lst.Add(node.val);}
}

相关文章:

Apache启动时报Could not reliably determine the server's fully qualified domain name

在系统启动时apache&#xff0c;没有启动起来&#xff0c;查看“事件查看器”发现报一些错误&#xff1a; The Apache service named reported the following error:>>> httpd.exe: Could not reliably determine the servers fully qualified domain name, using 19…

Windows Phone SDK update for Windows Phone 7.8

下载&#xff1a;http://www.microsoft.com/en-us/download/details.aspx?id36474 (在线安装) http://kuai.xunlei.com/d/cHbJCAIX4wBNVgFR5aa (离线下载 全语言 5.5G....) MS博客介绍&#xff1a;http://blogs.windows.com/windows_phone/b/wpdev/archive/2013/01/22/now-a…

作为一名合格的前端开发工程师需要会哪些

作为一名合格的前端开发工程师需要会哪些?web前端要学习的内容有很多&#xff0c;想要成为一名合格的web前端工程师&#xff0c;综合实力是要非常强的&#xff0c;来看看下面的详细介绍吧。 作为一名合格的前端开发工程师需要会哪些?前端开发工程师不仅要掌握基本的前端开发技…

memcached部署

第1章 memcached 1 memcached前言 1.1 memcached诞生的原因 2003年诞生了memcached Web1.0 2005以前 企业提供内容为主。 Web2.02005-2012 企业只提供平台&#xff0c;用户参与上传下载内容。 memcached 内存缓存软件&#xff0c;内存比磁盘快。 传统场景中&#xff0c;多数…

线性代数:第二章 矩阵及其运算

本讲义是自己上课所用幻灯片&#xff0c;里面没有详细的推导过程&#xff08;笔者板书推导&#xff09;只以大纲的方式来展示课上的内容&#xff0c;以方便大家下来复习。 本章主要介绍有关矩阵的知识&#xff0c;主要包括矩阵的基本运算&#xff08;加法、数乘、乘法、乘幂、…

sdut 2401 最大矩形面积

1http://acm.sdut.edu.cn/sdutoj/problem.php?actionshowproblem&problemid2401 /*2 最大矩形面积&#xff0c;把边界点加上3 从左往右 处理一遍&#xff1b;4 再从上往下处理一遍&#xff1b;5 */6 7 #include<stdio.h>8 #define maxn 200009 #include<cmath>…

Python中怎样改变集合之间的关系?

Python中怎样改变集合之间的关系?数学中&#xff0c;两个集合关系的常见操作包括&#xff1a;交集、并集、差集、补集。设A&#xff0c;B是两个集合&#xff0c;集合关系的操作介绍如下&#xff1a; 交集是指属于集合A且属于集合B的元素所组成的集合&#xff0c; 并集是指集合…

数据结构与算法:17 图

17 图 知识结构&#xff1a; 1. 图的基本概念与术语 1.1 图的定义 图由顶点集和边集组成&#xff0c;记为G(V,E)G(V,E)G(V,E)。 顶点集&#xff1a;顶点的有穷非空集合&#xff0c;记为V(G)V(G)V(G)。边集&#xff1a;顶点偶对的有穷集合&#xff0c;记为E(G)E(G)E(G) 。 …

云计算安全:技术与应用

云计算安全&#xff1a;技术与应用中国电信网络安全实验室 编著ISBN 978-7-121-14409-72012年1月出版定价&#xff1a;59.00元16开236页宣传语&#xff1a;全面了解云计算安全风险、安全防护手段的佳作&#xff01;内 容 简 介随着云计算的兴起&#xff0c;安全成为云计算能否顺…

再谈HOST文件

前几天弄了一个关于禁止打开某个网站的文章后&#xff0c;觉得这个HOST文件真的挺有意思的。并且也总是想把自己对它新的理解写下来&#xff08;也许大家都明白了&#xff09;以下是HOST文件的内容&#xff1a;# Copyright (c) 1993-1999 Microsoft Corp.## This is a sample H…

PMP®考试是什么机构

项目管理对于很多职场中的人来说是以后要发展的一个方向&#xff0c;随着各职业内卷也越来越严重&#xff0c;pmp认证引起了大家的关注&#xff0c;有朋友问&#xff1a;PMP考试是什么机构?下面我们给大家介绍一下。 PMP考试是什么机构?PMP考试认证在我国大陆地区需要三方机构…

技术图文:03 结构型设计模式(上)

结构型设计模式&#xff08;上&#xff09; 本教程主要介绍一系列用于如何将现有类或对象组合在一起形成更加强大结构的经验总结。 知识结构&#xff1a; 享元模式 – 实现对象的复用 Sunny 软件公司欲开发一个围棋软件&#xff0c;其界面效果如下图所示&#xff1a; 图2 围…

Linux抓包工具tcpdump详解

原文链接 tcpdump是一个用于截取网络分组&#xff0c;并输出分组内容的工具&#xff0c;简单说就是数据包抓包工具。tcpdump凭借强大的功能和灵活的截取策略&#xff0c;使其成为Linux系统下用于网络分析和问题排查的首选工具。 tcpdump提供了源代码&#xff0c;公开了接口&…

学习笔记TF065:TensorFlowOnSpark

2019独角兽企业重金招聘Python工程师标准>>> Hadoop生态大数据系统分为Yam、 HDFS、MapReduce计算框架。TensorFlow分布式相当于MapReduce计算框架&#xff0c;Kubernetes相当于Yam调度系统。TensorFlowOnSpark&#xff0c;利用远程直接内存访问(Remote Direct Memo…

HTML5培训好不好

HTML5培训好不好?这个问题&#xff0c;要看你选择的培训机构&#xff0c;想要学习HTML5技术&#xff0c;靠谱的培训机构非常重要&#xff0c;下面我们就来看看详细的介绍吧。 HTML5培训好不好?从前端开发的基础出发&#xff0c;学习使用HTML&#xff0c;CSS&#xff0c;JavaS…

技术图文:03 结构型设计模式(下)

结构型设计模式&#xff08;下&#xff09; 本教程主要介绍一系列用于如何将现有类或对象组合在一起形成更加强大结构的经验总结。 知识结构&#xff1a; 组合模式 – 树形结构的处理 Sunny 软件公司欲开发一个杀毒&#xff08;AntiVirus&#xff09;软件&#xff0c;该软件…

程序员必知8大排序3大查找(三)

前两篇 《程序员必知8大排序3大查找&#xff08;一&#xff09;》 《程序员必知8大排序3大查找&#xff08;二&#xff09;》 三种查找算法:顺序查找&#xff0c;二分法查找&#xff08;折半查找&#xff09;&#xff0c;分块查找&#xff0c;散列表&#xff08;以后谈&#xf…

MongoDB给数据库创建用户

转自http://www.imooc.com/article/18439 一.先以非授权的模式启动MongoDB非授权&#xff1a; linux/Mac : mongod -f /mongodb/etc/mongo.confwindows : mongod --config c:\mongodb\etc\mongo.conf 或者 net start mongodb &#xff08;前提是mongo安装到了服务里面&#xff…

如何挑选一家好的软件测试培训机构

随着智能时代的发展&#xff0c;我们的手机APP等各种软件都变得越来越复杂化、规模化&#xff0c;软件测试这一步骤是必不可少的&#xff0c;这也造就了这个行业的兴起&#xff0c;越来越多的人想要学习软件测试技术&#xff0c;想要知道如何挑选一家好的软件测试培训机构?来看…

POJ 3177 判决素数个数

时间限制: 1000ms内存限制:65536kB描述输入两个整数X和Y&#xff0c;输出两者之间的素数个数&#xff08;包括X和Y&#xff09;。输入两个整数X和Y&#xff0c;X和Y的大小任意。输出输出一个整数&#xff0c;结果可以是0&#xff0c;或大于0的整数。样例输入1 100样例输出25&am…

数据结构与算法:22 精选练习50

精选练习50 马上就要期末考试或者考研了。为了大家复习的方便&#xff0c;我精选了有关数据结构与算法的50道选择题&#xff0c;大家可以抽空练习一下。公众号后台回复“答案”可以获取该50道题目的答案。 01、数据在计算机中的表示称为数据的______。 &#xff08;A&#x…

极速理解设计模式系列:11.单例模式(Singleton Pattern)

单例模式&#xff1a;确保某一个类只有一个实例&#xff0c;而且自行实例化并向整个系统提供这个实例。这个类称为单例类。 三要点&#xff1a; 一、单例类只能有一个实例 二、单例类必须自行创建自身实例 三、单例类自行向整个系统提供实例 类图&#xff1a; 应用场景&#xf…

参加web前端培训要学哪些知识

IT行业&#xff0c;web前端技术是比较吃香的&#xff0c;也是工资待遇非常高的行业之一&#xff0c;如果想要做一名合格的web前端工程师&#xff0c;系统学习是非常重要的&#xff0c;那么参加web前端培训要学哪些知识呢?来看看下面的详细介绍。 参加web前端培训要学哪些知识?…

数据结构与算法:19 排序

19 排序 知识结构&#xff1a; 1. 排序的基本概念与术语 假设含有nnn个记录的序列为{r1,r2,⋯,rn}\lbrace r_1,r_2,\cdots,r_n \rbrace{r1​,r2​,⋯,rn​}&#xff0c;其相应的关键字分别为{k1,k2,⋯,kn}\lbrace k_1,k_2,\cdots,k_n \rbrace{k1​,k2​,⋯,kn​}&#xff0c;…

Objective-C 什么是类

Objective-C 什么是类 转自http://www.189works.com/article-31219-1.html 之前一直做C开发&#xff0c;最近2个多月转 Objective-C&#xff0c; 入门的时候&#xff0c;遇到了很多的困惑。现在过节&#xff0c;正是解决他们的好时机。 主要参考来自http://www.sealiesoftware.…

APP之红点提醒三个阶段

下面这个页面就是我们进入APP后的主界面。客户选项的红点上数字就是显示我们没有查看的客户总数量。 当我们切换到客户这个fragment时&#xff0c;会显示贷款客户数量与保险客户数量。 当我们随便点击入一个选项&#xff0c;假如进入到保险客户的这个activity里面&#xff0c;L…

零基础参加java培训的系统学习路线

​ 零基础想要学习java技术&#xff0c;那么最好的选择就是参加java培训&#xff0c;进行系统的学习&#xff0c;以下就是小编为大家整理的零基础参加java培训的系统学习路线&#xff0c;希望能够帮助到正在学习java技术的零基础同学。 零基础参加java培训的系统学习路线&#…

在ASP.NET中跟踪和恢复大文件下载

在Web应用程序中处理大文件下载的问题一直出了名的困难&#xff0c;因此对于大多数站点来说&#xff0c;如果用户的下载被中断了&#xff0c;它们只能说悲哀降临到用户的身上了。但是我们现在不必这样了&#xff0c;因为你可以使自己的ASP.NET应用程序有能力支持可恢复&#xf…

ZeroMQ实例-使用ZeroMQ进行windows与linux之间的通信

1、本文包括 1&#xff09;在windows下使用ZMQ 2&#xff09;在windows环境下与Linux环境下进行网络通信 2、在Linux下使用ZMQ 之前写过一篇如何在Linux环境下使用ZMQ的文章 《ZeroMQ实例-使用ZMQ(ZeroMQ)进行局域网内网络通信》&#xff0c;这里就不再赘述。 3、在Windows环境…

线性代数:03 向量空间 -- 基本概念

本讲义是自己上课所用幻灯片&#xff0c;里面没有详细的推导过程&#xff08;笔者板书推导&#xff09;只以大纲的方式来展示课上的内容&#xff0c;以方便大家下来复习。 本章主要介绍向量空间的知识&#xff0c;与前两章一样本章也可以通过研究解线性方程组的解把所有知识点…