Leetcode刷题笔记

白天 夜间 首页 下载 阅读记录
  我的书签   添加书签   移除书签

shuffle-the-array

浏览 131 扫码 分享 2023-11-24 19:50:33
  • 1470. 重新排列数组">1470. 重新排列数组
    • 思路
    • 代码

    1470. 重新排列数组

    思路

    签到题一般没什么难度,元素个数为2n个,我们只用遍历n,然后交叉着添加到新数组中。AC!

    代码

    python3

    1. class Solution:
    2. def shuffle(self, nums: List[int], n: int) -> List[int]:
    3. result = []
    4. for i in range(n):
    5. result.append(nums[i])
    6. result.append(nums[i+n])
    7. return result

    若有收获,就点个赞吧

    0 人点赞

    上一篇:
    下一篇:
    • 书签
    • 添加书签 移除书签
    • 目录
      • excel-sheet-column-number
      • divide-two-integers
      • house-robber
      • fraction-to-recurring-decimal
      • profile
      • kids-with-the-greatest-number-of-candies
      • qiu-12n-lcof
      • new-21-game
      • product-of-array-except-self
      • minimum-depth-of-binary-tree
      • univalued-binary-tree
      • shun-shi-zhen-da-yin-ju-zhen-lcof
      • permutations
      • satisfiability-of-equality-equations
      • word-ladder-ii
      • ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof
      • palindrome-number
      • network-delay-time
      • daily-temperatures
      • longest-common-prefix
    • 周赛专题
      • make-two-arrays-equal-by-reversing-sub-arrays
      • check-if-a-string-contains-all-binary-codes-of-size-k
      • course-schedule-iv
      • cherry-pickup-ii
      • maximum-product-of-two-elements-in-an-array
      • maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
      • reorder-routes-to-make-all-paths-lead-to-the-city-zero
      • probability-of-a-two-boxes-having-the-same-number-of-distinct-balls
      • shuffle-the-array
      • the-k-strongest-values-in-an-array
      • design-browser-history
      • paint-house-iii
    暂无相关搜索结果!

      让时间为你证明

      展开/收起文章目录

      分享,让知识传承更久远

      文章二维码

      手机扫一扫,轻松掌上读

      文档下载

      请下载您需要的格式的文档,随时随地,享受汲取知识的乐趣!
      PDF文档 EPUB文档 MOBI文档

      书签列表

        阅读记录

        阅读进度: 0.00% ( 0/0 ) 重置阅读进度

          思维导图备注