题目要求

Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.

题目分析及思路

题目给出一个整数数组,已经按照非减顺序排列好了。要求返回一个数组,包含的元素是已知数组元素的平方,且按照非减顺序排列。可以使用列表的sort()函数进行排序。

python代码​

class Solution:

def sortedSquares(self, A):

"""

:type A: List[int]

:rtype: List[int]

"""

B = list()

for i in A:

B.append(i**2)

B.sort()

return B

LeetCode 977 Squares of a Sorted Array 解题报告的更多相关文章

  1. 【LeetCode】977. Squares of a Sorted Array 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 排序 日期 题目地址:https://leetcod ...

  2. #Leetcode# 977. Squares of a Sorted Array

    https://leetcode.com/problems/squares-of-a-sorted-array/ Given an array of integers A sorted in non- ...

  3. LeetCode 977. Squares of a Sorted Array (有序数组的平方)

    题目标签:Array 题目给了我们一组 从小到大的 integers,让我们平方数字 并且 也排序成 从小到达. 因为有负数在里面,平方后,负数在array的位置会变动. 可以设left 和 righ ...

  4. 【Leetcode_easy】977. Squares of a Sorted Array

    problem 977. Squares of a Sorted Array solution: class Solution { public: vector<int> sortedSq ...

  5. 【LeetCode】153. Find Minimum in Rotated Sorted Array 解题报告(Python)

    [LeetCode]153. Find Minimum in Rotated Sorted Array 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode. ...

  6. 【LeetCode】697. Degree of an Array 解题报告

    [LeetCode]697. Degree of an Array 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/degree- ...

  7. LeetCode: Search in Rotated Sorted Array 解题报告

    Search in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you before ...

  8. LeetCode 新题: Find Minimum in Rotated Sorted Array 解题报告-二分法模板解法

    Find Minimum in Rotated Sorted Array Question Solution Suppose a sorted array is rotated at some piv ...

  9. 【LeetCode】Find Minimum in Rotated Sorted Array 解题报告

    今天看到LeetCode OJ题目下方多了"Show Tags"功能.我觉着挺好,方便刚開始学习的人分类练习.同一时候也是解题时的思路提示. [题目] Suppose a sort ...

随机推荐

  1. rman list命令

    rman list命令   List command example 可以用于查看backup,copy,archivelog等 01 list incarnation================ ...

  2. HttpWebRequest - Asynchronous Programming Model/Task.Factory.FromAsyc

    Posted by Shiv Kumar on 23rd February, 2011 The Asynchronous Programming Model (or APM) has been aro ...

  3. 如何解决安装VMware后郑广电宽带客户端不能登录的问题?

    如何解决安装VMware后郑广电宽带客户端不能登录的问题? 问题:安装VMware后,郑广电宽带客户端不能登录,提示:“不允许代理上网”. 解决:将VMware的虚拟网卡(VMnet1和VMnet8) ...

  4. 实验室ubuntu连ipv6

    1.买个极路由 2.无线中继连tsinghua-5G 3.安装ipv6插件 4.联网或者科协vpn 5.下载bt客户端:sudo apt-get install qbittorrent   (或者su ...

  5. svn-checkout后,循环遍历查找包含某字符串的文件

    这里涉及几个知识点: 1.安装subversion,不多说了,网上有教程 2.循环遍历所有目录层级,找相 关文件 #!/bin/bash #########svn checkout项目出来 svn_d ...

  6. Docker GitLab镜像部署

    环境说明 系统环境: CentOS Linux release 7.4 docker Version: 18.03.1-ce 运行镜像 docker run --detach \ --hostname ...

  7. MySQL主从介绍 准备工作 配置主 配置从 测试主从同步

    配置主: • 安装mysql • 修改my.cnf,增加server-id=130和log_bin=xiaobo1 • 添加环境变量 Vim /root/.bash_profile PATH=$PAT ...

  8. QT下载区

    http://download.qt.io/archive/qt/ 下载总网址: http://download.qt.io/ http://mirrors.hust.edu.cn/qtproject ...

  9. [原]Jenkins(八)---jenkins构建项目报错时发送错误报告邮件

    /** * lihaibo * 文章内容都是根据自己工作情况实践得出. * 版权声明:本博客欢迎转发,但请保留原作者信息! http://www.cnblogs.com/horizonli/p/533 ...

  10. SSL、数字签名、CA 工作原理通俗描述

    SSL(Secure Socket Layer) 是一种加密技术,可以提供对称加密和非对称加密.由于它在协议层里正好是在传输层与应用层之间,这就决定了上层应用必须经过它,这就是它广泛流行和易于实现的原 ...