Python Numpy入门基础(二)数组操作

news2024/9/23 19:19:05

9a6d821e8f414c749ef1143368e115ee.png

入门基础(二)

NumPy是Python中一个重要的数学运算库,它提供了了一组多维数组对象和一组用于操作这些数组的函数。以下是一些NumPy的主要特点:

  1. 多维数组对象:NumPy的核心是ndarray对象,它是一个多维数组对象,可以容纳任意数据类型。
  2. 矢量化操作:使用NumPy的函数,可以对整个数组进行操作,而不需要显式循环。
  3. 广播:NumPy的广播机制允许对不同形状的数组执行算术操作,而无需进行显式循环或手动对齐。
  4. 易于扩展:NumPy可以用C或C++扩展,以加速大型数值计算任务。
  5. 强大的函数库:NumPy提供了许多用于线性代数、傅里叶分析、随机数生成等领域的函数。
  6. 易于使用:NumPy与Python的内置数据结构无缝集成,因此可以轻松地将Python代码转换为使用NumPy。

数组操作

组索引和切片

索引从0开始,索引值不能超过长度,否则会报IndexError错误。

一维数组的索引和切片

>>> import numpy as np
>>> a = np.array([1,2,3,4,5])
>>> a[2]
3
>>> a[1:4:2]
array([2, 4])
>>> a[1:3]
array([2, 3])
>>> a[0::2]
array([1, 3, 5])
>>> a[5]
Traceback (most recent call last):
  File "<pyshell#15>", line 1, in <module>
    a[5]
IndexError: index 5 is out of bounds for axis 0 with size 5

多维数组的索引

>>> import numpy as np
>>> a = np.arange(24).reshape((2,3,4))
>>> a
array([[[ 0,  1,  2,  3],
        [ 4,  5,  6,  7],
        [ 8,  9, 10, 11]],

       [[12, 13, 14, 15],
        [16, 17, 18, 19],
        [20, 21, 22, 23]]])
>>> a[1,2,3]
23
>>> a[-1,-2,-3]
17
>>> a[0,2,2]
10
>>> a[0,3,3]
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    a[0,3,3]
IndexError: index 3 is out of bounds for axis 1 with size 3

多维数组切片

>>> import numpy as np
>>> a = np.arange(24).reshape((2,3,4)) + 1
>>> a
array([[[ 1,  2,  3,  4],
        [ 5,  6,  7,  8],
        [ 9, 10, 11, 12]],

       [[13, 14, 15, 16],
        [17, 18, 19, 20],
        [21, 22, 23, 24]]])
>>> a[:1,2]
array([[ 9, 10, 11, 12]])
>>> a[:,1:3,:]
array([[[ 5,  6,  7,  8],
        [ 9, 10, 11, 12]],

       [[17, 18, 19, 20],
        [21, 22, 23, 24]]])
>>> a[:,:,::2]
array([[[ 1,  3],
        [ 5,  7],
        [ 9, 11]],

       [[13, 15],
        [17, 19],
        [21, 23]]])
>>> a[:,:,1::2]
array([[[ 2,  4],
        [ 6,  8],
        [10, 12]],

       [[14, 16],
        [18, 20],
        [22, 24]]])
>>> a[1:3,:,:]
array([[[13, 14, 15, 16],
        [17, 18, 19, 20],
        [21, 22, 23, 24]]])
>>> a[1:3,1:3,:]
array([[[17, 18, 19, 20],
        [21, 22, 23, 24]]])
>>> a[1:3,1:3,1:3]
array([[[18, 19],
        [22, 23]]])

通过布尔数组访问数组元素

>>> import numpy as np
>>> a = np.array([1, 2, 3, 4, 5])
>>> b = np.array([True, False, True, False, True])
>>> a[b]
array([1, 3, 5])
>>> b = np.array([False, True, False, True, False])
>>> a[b]
array([2, 4])
>>> b = a<=3
>>> a[b]
array([1, 2, 3])
>>> b = a%2==0
>>> a[b]
array([2, 4])
>>> b = a%2==1
>>> a[b]
array([1, 3, 5])

数组的整体操作

数组的拼接

在 NumPy 中,可以使用多种方法来拼接数组。以下是一些常用的方法:

numpy.concatenate()

这个函数用于连接两个数组,沿指定的轴在末尾添加第二个数组的元素。

>>> a = np.array([[1, 2], [3, 4]])
>>> b = np.array([[5, 6]])
>>> np.concatenate((a, b), axis=0)
array([[1, 2],
      [3, 4],
      [5, 6]])
>>> np.concatenate((a, b.T), axis=1)
array([[1, 2, 5],
      [3, 4, 6]])
>>> np.concatenate((a, b), axis=None)
array([1, 2, 3, 4, 5, 6])
numpy.vstack()

这个函数用于垂直方向拼接数组,即行方向添加第二个数组的元素。

>>> a = np.array([1, 2, 3])
>>> b = np.array([4, 5, 6])
>>> np.vstack((a,b))
array([[1, 2, 3],
      [4, 5, 6]])

>>> a = np.array([[1], [2], [3]])
>>> b = np.array([[4], [5], [6]])
>>> np.vstack((a,b))
array([[1],
      [2],
      [3],
      [4],
      [5],
      [6]])
numpy.hstack()

这个函数用于水平方向拼接数组,即列方向添加第二个数组的元素。

>>> a = np.array((1,2,3))
>>> b = np.array((4,5,6))
>>> np.hstack((a,b))
array([1, 2, 3, 4, 5, 6])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[4],[5],[6]])
>>> np.hstack((a,b))
array([[1, 4],
       [2, 5],
       [3, 6]])
numpy.row_stack()

这个函数是vstack的alias,别名就是同一个函数。

>>> import numpy as np
>>> a = np.array([[1, 2], [3, 4]])
>>> b = np.array([[5, 6]])
>>> np.row_stack((a, b))
array([[1, 2],
       [3, 4],
       [5, 6]])

在使用这些函数时,需要确保拼接的数组具有相同的维度,或者在使用 numpy.column_stack() 时具有相同的列数。如果维度不同,可以使用 numpy.reshape() 函数对数组进行重塑。

数组的翻转

在 NumPy 中,也有多种方法可以翻转数组。以下是一些常用的方法:

numpy.flip()

这个函数用于沿指定的轴翻转数组。

    Examples
    --------
    >>> A = np.arange(8).reshape((2,2,2))
    >>> A
    array([[[0, 1],
            [2, 3]],
           [[4, 5],
            [6, 7]]])
    >>> np.flip(A, 0)
    array([[[4, 5],
            [6, 7]],
           [[0, 1],
            [2, 3]]])
    >>> np.flip(A, 1)
    array([[[2, 3],
            [0, 1]],
           [[6, 7],
            [4, 5]]])
    >>> np.flip(A)
    array([[[7, 6],
            [5, 4]],
           [[3, 2],
            [1, 0]]])
    >>> np.flip(A, (0, 2))
    array([[[5, 4],
            [7, 6]],
           [[1, 0],
            [3, 2]]])
    >>> A = np.random.randn(3,4,5)
    >>> np.all(np.flip(A,2) == A[:,:,::-1,...])
    True

numpy.flipud()

这个函数用于垂直方向翻转数组,即行方向翻转。

    Examples
    --------
    >>> A = np.diag([1.0, 2, 3])
    >>> A
    array([[1.,  0.,  0.],
           [0.,  2.,  0.],
           [0.,  0.,  3.]])
    >>> np.flipud(A)
    array([[0.,  0.,  3.],
           [0.,  2.,  0.],
           [1.,  0.,  0.]])
    
    >>> A = np.random.randn(2,3,5)
    >>> np.all(np.flipud(A) == A[::-1,...])
    True
    
    >>> np.flipud([1,2])
    array([2, 1])

numpy.fliplr()

这个函数用于水平方向翻转数组,即列方向翻转。

    Examples
    --------
    >>> A = np.diag([1.,2.,3.])
    >>> A
    array([[1.,  0.,  0.],
           [0.,  2.,  0.],
           [0.,  0.,  3.]])
    >>> np.fliplr(A)
    array([[0.,  0.,  1.],
           [0.,  2.,  0.],
           [3.,  0.,  0.]])
    
    >>> A = np.random.randn(2,3,5)
    >>> np.all(np.fliplr(A) == A[:,::-1,...])
    True

在使用这些函数时,需要确保数组的维度适合进行翻转。

数组的复制

    Examples
    --------
    Create an array x, with a reference y and a copy z:
    
    >>> x = np.array([1, 2, 3])
    >>> y = x
    >>> z = np.copy(x)
    
    Note that, when we modify x, y changes, but not z:
    
    >>> x[0] = 10
    >>> x[0] == y[0]
    True
    >>> x[0] == z[0]
    False
    
    Note that, np.copy clears previously set WRITEABLE=False flag.
    
    >>> a = np.array([1, 2, 3])
    >>> a.flags["WRITEABLE"] = False
    >>> b = np.copy(a)
    >>> b.flags["WRITEABLE"]
    True
    >>> b[0] = 3
    >>> b
    array([3, 2, 3])
    
    Note that np.copy is a shallow copy and will not copy object
    elements within arrays. This is mainly important for arrays
    containing Python objects. The new array will contain the
    same object which may lead to surprises if that object can
    be modified (is mutable):
    
    >>> a = np.array([1, 'm', [2, 3, 4]], dtype=object)
    >>> b = np.copy(a)
    >>> b[2][0] = 10
    >>> a
    array([1, 'm', list([10, 3, 4])], dtype=object)
    
    To ensure all elements within an ``object`` array are copied,
    use `copy.deepcopy`:
    
    >>> import copy
    >>> a = np.array([1, 'm', [2, 3, 4]], dtype=object)
    >>> c = copy.deepcopy(a)
    >>> c[2][0] = 10
    >>> c
    array([1, 'm', list([10, 3, 4])], dtype=object)
    >>> a
    array([1, 'm', list([2, 3, 4])], dtype=object)

数组的排序

    Examples
    --------
    >>> a = np.array([[1,4],[3,1]])
    >>> np.sort(a)                # sort along the last axis
    array([[1, 4],
           [1, 3]])
    >>> np.sort(a, axis=None)     # sort the flattened array
    array([1, 1, 3, 4])
    >>> np.sort(a, axis=0)        # sort along the first axis
    array([[1, 1],
           [3, 4]])
    
    Use the `order` keyword to specify a field to use when sorting a
    structured array:
    
    >>> dtype = [('name', 'S10'), ('height', float), ('age', int)]
    >>> values = [('Arthur', 1.8, 41), ('Lancelot', 1.9, 38),
    ...           ('Galahad', 1.7, 38)]
    >>> a = np.array(values, dtype=dtype)       # create a structured array
    >>> np.sort(a, order='height')                        # doctest: +SKIP
    array([('Galahad', 1.7, 38), ('Arthur', 1.8, 41),
           ('Lancelot', 1.8999999999999999, 38)],
          dtype=[('name', '|S10'), ('height', '<f8'), ('age', '<i4')])
    
    Sort by age, then height if ages are equal:
    
    >>> np.sort(a, order=['age', 'height'])               # doctest: +SKIP
    array([('Galahad', 1.7, 38), ('Lancelot', 1.8999999999999999, 38),
           ('Arthur', 1.8, 41)],
          dtype=[('name', '|S10'), ('height', '<f8'), ('age', '<i4')])


数组的数学操作

加法

>>> added_arr = arr1 + arr2

减法

>>> subtracted_arr = arr1 - arr2

乘法

>>> multiplied_arr = arr1 * arr2

除法

>>> divided_arr = arr1 / arr2

幂运算

>>> power_arr = np.power(arr1, arr2)


数组的统计操作

均值

mean = np.mean(arr)

    Examples
    --------
    >>> a = np.array([[1, 2], [3, 4]])
    >>> np.mean(a)
    2.5
    >>> np.mean(a, axis=0)
    array([2., 3.])
    >>> np.mean(a, axis=1)
    array([1.5, 3.5])
    
    In single precision, `mean` can be inaccurate:
    
    >>> a = np.zeros((2, 512*512), dtype=np.float32)
    >>> a[0, :] = 1.0
    >>> a[1, :] = 0.1
    >>> np.mean(a)
    0.54999924
    
    Computing the mean in float64 is more accurate:
    
    >>> np.mean(a, dtype=np.float64)
    0.55000000074505806 # may vary
    
    Specifying a where argument:
    
    >>> a = np.array([[5, 9, 13], [14, 10, 12], [11, 15, 19]])
    >>> np.mean(a)
    12.0
    >>> np.mean(a, where=[[True], [False], [False]])
    9.0

方差

var = np.var(arr)

    Examples
    --------
    >>> a = np.array([[1, 2], [3, 4]])
    >>> np.var(a)
    1.25
    >>> np.var(a, axis=0)
    array([1.,  1.])
    >>> np.var(a, axis=1)
    array([0.25,  0.25])
    
    In single precision, var() can be inaccurate:
    
    >>> a = np.zeros((2, 512*512), dtype=np.float32)
    >>> a[0, :] = 1.0
    >>> a[1, :] = 0.1
    >>> np.var(a)
    0.20250003
    
    Computing the variance in float64 is more accurate:
    
    >>> np.var(a, dtype=np.float64)
    0.20249999932944759 # may vary
    >>> ((1-0.55)**2 + (0.1-0.55)**2)/2
    0.2025
    
    Specifying a where argument:
    
    >>> a = np.array([[14, 8, 11, 10], [7, 9, 10, 11], [10, 15, 5, 10]])
    >>> np.var(a)
    6.833333333333333 # may vary
    >>> np.var(a, where=[[True], [True], [False]])
    4.0

标准差

std = np.std(arr)

    Examples
    --------
    >>> a = np.array([[1, 2], [3, 4]])
    >>> np.std(a)
    1.1180339887498949 # may vary
    >>> np.std(a, axis=0)
    array([1.,  1.])
    >>> np.std(a, axis=1)
    array([0.5,  0.5])
    
    In single precision, std() can be inaccurate:
    
    >>> a = np.zeros((2, 512*512), dtype=np.float32)
    >>> a[0, :] = 1.0
    >>> a[1, :] = 0.1
    >>> np.std(a)
    0.45000005
    
    Computing the standard deviation in float64 is more accurate:
    
    >>> np.std(a, dtype=np.float64)
    0.44999999925494177 # may vary
    
    Specifying a where argument:
    
    >>> a = np.array([[14, 8, 11, 10], [7, 9, 10, 11], [10, 15, 5, 10]])
    >>> np.std(a)
    2.614064523559687 # may vary
    >>> np.std(a, where=[[True], [True], [False]])
    2.0

最大值、最小值

max_value = np.max(arr)

    Examples
    --------
    >>> a = np.arange(4).reshape((2,2))
    >>> a
    array([[0, 1],
           [2, 3]])
    >>> np.amax(a)           # Maximum of the flattened array
    3
    >>> np.amax(a, axis=0)   # Maxima along the first axis
    array([2, 3])
    >>> np.amax(a, axis=1)   # Maxima along the second axis
    array([1, 3])
    >>> np.amax(a, where=[False, True], initial=-1, axis=0)
    array([-1,  3])
    >>> b = np.arange(5, dtype=float)
    >>> b[2] = np.NaN
    >>> np.amax(b)
    nan
    >>> np.amax(b, where=~np.isnan(b), initial=-1)
    4.0
    >>> np.nanmax(b)
    4.0
    
    You can use an initial value to compute the maximum of an empty slice, or
    to initialize it to a different value:
    
    >>> np.amax([[-50], [10]], axis=-1, initial=0)
    array([ 0, 10])
    
    Notice that the initial value is used as one of the elements for which the
    maximum is determined, unlike for the default argument Python's max
    function, which is only used for empty iterables.
    
    >>> np.amax([5], initial=6)
    6
    >>> max([5], default=6)
    5

min_value = np.min(arr)

    Examples
    --------
    >>> a = np.arange(4).reshape((2,2))
    >>> a
    array([[0, 1],
           [2, 3]])
    >>> np.amin(a)           # Minimum of the flattened array
    0
    >>> np.amin(a, axis=0)   # Minima along the first axis
    array([0, 1])
    >>> np.amin(a, axis=1)   # Minima along the second axis
    array([0, 2])
    >>> np.amin(a, where=[False, True], initial=10, axis=0)
    array([10,  1])
    
    >>> b = np.arange(5, dtype=float)
    >>> b[2] = np.NaN
    >>> np.amin(b)
    nan
    >>> np.amin(b, where=~np.isnan(b), initial=10)
    0.0
    >>> np.nanmin(b)
    0.0
    
    >>> np.amin([[-50], [10]], axis=-1, initial=0)
    array([-50,   0])
    
    Notice that the initial value is used as one of the elements for which the
    minimum is determined, unlike for the default argument Python's max
    function, which is only used for empty iterables.
    
    Notice that this isn't the same as Python's ``default`` argument.
    
    >>> np.amin([6], initial=5)
    5
    >>> min([6], default=5)
    6

9a6d821e8f414c749ef1143368e115ee.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/806855.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

TCP/IP协议详解(二)

目录内容 TCP协议的可靠性 TCP的三次握手 TCP的四次挥手 C#中&#xff0c;TCP/IP建立 三次握手和四次挥手常见面试题 在上一篇文章中讲解了TCP/IP的由来以及报文格式&#xff0c;详情请见上一篇文章&#xff0c;现在接着来讲讲TCP/IP的可靠性以及通过代码的实现。 在TCP首部的…

Javadoc comment自动生成

光标放在第二行 按下Alt Shift j 下面是Java doc的生成 Next Next-> Finish

java多线程(超详细)

1 - 线程 1.1 - 进程 进程就是正在运行中的程序&#xff08;进程是驻留在内存中的&#xff09; 是系统执行资源分配和调度的独立单位 每一进程都有属于自己的存储空间和系统资源 注意&#xff1a;进程A和进程B的内存独立不共享。 1.2 - 线程 线程就是进程中的单个顺序控制…

【数据预测】基于蜣螂优化算法DBO的VMD-KELM光伏发电功率预测 短期功率预测【Matlab代码#53】

文章目录 【可更换其他算法&#xff0c;获取资源请见文章第6节&#xff1a;资源获取】1. 蜣螂优化算法DBO2. 变分模态分解VMD3. 核极限学习机KELM4. 部分代码展示5. 仿真结果展示6. 资源获取 【可更换其他算法&#xff0c;获取资源请见文章第6节&#xff1a;资源获取】 1. 蜣螂…

【雕爷学编程】Arduino动手做(175)---机智云ESP8266开发板模块8

37款传感器与执行器的提法&#xff0c;在网络上广泛流传&#xff0c;其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块&#xff0c;依照实践出真知&#xff08;一定要动手做&#xff09;的理念&#xff0c;以学习和交流为目的&am…

二、vagrant中安装centos-7

篇章二、vagrant中安装centos-7 前言 使用Vagrant创建镜像时&#xff0c;需要指定一个镜像&#xff0c;也就是box&#xff0c;若不存在Vagrant则会先从网上下载&#xff0c;而后缓存在本地目录下。 Vagrant有一个 镜像网站 &#xff0c;可以根据需要在这个网站中下载所需镜像…

Banana Pi 推出带有 2 个 2.5GbE 端口的迷你路由器开源硬件开发板

Banana Pi 今天推出了一款迷你路由器板&#xff0c;基于 MediaTek MT7986 无线网络片上系统&#xff0c;针对路由器进行了优化。Banana Pi BPI-R3 迷你路由器板还支持无线连接&#xff0c;起价约为 78.95 美元。 产品公告显示&#xff0c;这款新路由器板集成了 MediaTek Filog…

LAL v0.34.3发布,G711音频来了,Web UI也来了

Go语言流媒体开源项目 LAL 今天发布了v0.34.3版本。 LAL 项目地址&#xff1a;https://github.com/q191201771/lal 老规矩&#xff0c;简单介绍一下&#xff1a; ▦ 一. 音频G711 新增了对音频G711A/G711U(也被称为PCMA/PCMU)的支持。主要表现在&#xff1a; ✒ 1) rtmp G71…

《向量数据库指南》——使用Milvus Cloud操作员安装Milvus Cloud独立版

Milvus cloud操作员HelmDocker Compose Milvus cloud Operator是一种解决方案,帮助您在目标Kubernetes(K8s)集群上部署和管理完整的Milvus cloud服务堆栈。该堆栈包含所有Milvus cloud组件和相关依赖项,如etcd、Pulsar和MinIO。本主题介绍如何使用Milvus cloud Operator安…

Git的安装以及本地仓库的创建和配置

文章目录 1.Git简介2.安装Git2.1在Centos上安装git2.2 在ubuntu上安装git 3.创建本地仓库4.配置本地仓库 1.Git简介 Git是一个分布式版本控制系统&#xff0c;用于跟踪和管理文件的更改。它可以记录和存储代码的所有历史版本&#xff0c;并可以方便地进行分支管理、合并代码和协…

01_补充)docker学习 centos7 yum指令在线安装docker

安装前环境确认 目前,CentOS 仅发行版本中的内核支持 Docker。 Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。 Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。 1.查看Linux 版本 …

DLA :pytorch添加算子

pytorch的C extension写法 这部分主要介绍如何在pytorch中添加自定义的算子&#xff0c;需要以下cuda基础。就总体的逻辑来说正向传播需要输入数据&#xff0c;反向传播需要输入数据和上一层的梯度&#xff0c;然后分别实现这两个kernel,将这两个kernerl绑定到pytorch即可。 a…

iOS开发-聊天emoji表情与自定义动图表情左右滑动控件

iOS开发-聊天emoji表情与自定义动图表情左右滑动控件 之前开发中遇到需要实现聊天emoji表情与自定义动图表情左右滑动控件。使用UICollectionView实现。 一、效果图 二、实现代码 UICollectionView是一种类似于UITableView但又比UITableView功能更强大、更灵活的视图&#x…

window.location.href is not a function

在使用uniapp跳转到外部页面时&#xff0c;使用window.location.href报错 解决&#xff1a; 当出现"window.location.href is not a function"的错误时&#xff0c;这通常是因为在某些浏览器中&#xff0c;window.location.href被视为只读属性&#xff0c;而不是函…

时频分析方法的matlab实现

傅里叶变换 function [ output_args ] example3_7( input_args ) %EXAMPLE3_7 Summary of this function goes here % Detailed explanation goes here clc; clear; fs12800;%采样频率 s1load(Sig1.txt); s2load(Sig2.txt); lslength(s1); figure(1) subplot(211) plot…

c++11 标准模板(STL)(std::basic_filebuf)(八)

定义于头文件 <fstream> template< class CharT, class Traits std::char_traits<CharT> > class basic_filebuf : public std::basic_streambuf<CharT, Traits> std::basic_filebuf 是关联字符序列为文件的 std::basic_streambuf 。输入序…

【力扣每日一题】2023.7.29 环形链表

目录 题目&#xff1a; 示例&#xff1a; 分析&#xff1a; 代码&#xff1a; 题目&#xff1a; 示例&#xff1a; 分析&#xff1a; 题目给我们一个链表&#xff0c;让我们判断这个链表是否有环。我们可以直接遍历这个链表&#xff0c;最后能走到链表末尾也就是空指针那就…

Go语言进阶语法八万字详解,通俗易懂

文章目录 File文件操作FileInfo接口权限打开模式File操作文件读取 I/O操作io包 文件复制io包下的Read()和Write()io包下的Copy()ioutil包总结 断点续传Seeker接口断点续传 bufio包bufio包原理Reader对象Writer对象 bufio包bufio.Readerbufio.Writer ioutil包ioutil包的方法示例…

wps图表怎么改横纵坐标,MLP 多层感知器和CNN卷积神经网络区别

目录 wps表格横纵坐标轴怎么设置&#xff1f; MLP (Multilayer Perceptron) 多层感知器 CNN (Convolutional Neural Network) 卷积神经网络 多层感知器MLP&#xff0c;全连接网络&#xff0c;DNN三者的关系 wps表格横纵坐标轴怎么设置&#xff1f; 1、打开表格点击图的右侧…

LeetCode559. N 叉树的最大深度

559. N 叉树的最大深度 文章目录 [559. N 叉树的最大深度](https://leetcode.cn/problems/maximum-depth-of-n-ary-tree/)一、题目二、题解方法一&#xff1a;迭代方法二&#xff1a;递归 一、题目 给定一个 N 叉树&#xff0c;找到其最大深度。 最大深度是指从根节点到最远叶…