【leetcode】977. Squares of a Sorted Array
题目如下:
Given an array of integers
Asorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.Example 1:
Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]Example 2:
Input: [-7,-3,2,3,11]
Output: [4,9,9,49,121]Note:
1 <= A.length <= 10000-10000 <= A[i] <= 10000Ais sorted in non-decreasing order.
解题思路:在leetcode,还有比这更简单的题目吗?
闲聊:最近在出差,都没有时间刷题。今天刷个容易的题保持手感吧。
代码如下:
class Solution(object):
def sortedSquares(self, A):
"""
:type A: List[int]
:rtype: List[int]
"""
def f(x):
return x*x
return sorted(map(f,A))
【leetcode】977. Squares of a Sorted Array的更多相关文章
- 【LeetCode】977. Squares of a Sorted Array 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 排序 日期 题目地址:https://leetcod ...
- 【Leetcode_easy】977. Squares of a Sorted Array
problem 977. Squares of a Sorted Array solution: class Solution { public: vector<int> sortedSq ...
- 【leetcode】Find Minimum in Rotated Sorted Array I&&II
题目概述: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 ...
- 【LeetCode】Find Minimum in Rotated Sorted Array 解题报告
今天看到LeetCode OJ题目下方多了"Show Tags"功能.我觉着挺好,方便刚開始学习的人分类练习.同一时候也是解题时的思路提示. [题目] Suppose a sort ...
- 【leetcode】Find Minimum in Rotated Sorted Array II JAVA实现
一.题目描述 Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed ...
- 【leetcode】 26. Remove Duplicates from Sorted Array
@requires_authorization @author johnsondu @create_time 2015.7.22 18:58 @url [remove dublicates from ...
- 【LeetCode】26. Remove Duplicates from Sorted Array 解题报告(Python&C++&Java)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 日期 [LeetCode] https:// ...
- 【LeetCode】81. Search in Rotated Sorted Array II 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/search-in ...
- 【LeetCode】80. Remove Duplicates from Sorted Array II 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
随机推荐
- 42th-2
''' 1, 元祖(2,3)'''def summ2(self, *args): '''这是一个求一系列数平方和的函数''' s = 0 for i in args: #历遍元 ...
- docker cassandra集群搭建
1.使用daocloud的镜像,创建docker集群 启用一个node docker run -d --name cassandra -p 9042:9042 daocloud.io/library/ ...
- CascadeCNN人脸检测结构
模型的结构大致由图可以完整展现,三个分类是否人脸的12.24.48net,再加上三个用于修正预测框的分类网络: 这三个分类是否人脸的网络,结构逐渐变复杂, 由上图可以看出,前2阶的网络都非常简单,只有 ...
- jquery submit事件
jquery submit 事件 $('#form').submit(function(){ if(true){ //do return true; }else{ //do return false; ...
- idea创建ssm框架步骤
打开idea 编辑器 File>new >project 选择Maven 右边勾选Create from archctype 然后下拉选择org.apache.maven.archet ...
- SLA(服务等级协议)
SLA:Service-Level Agreement的缩写,意思是服务等级协议.是关于网络服务供应商和客户间的一份合同,其中定义了服务类型.服务质量和客户付款等术语. 定义SLA:Service-L ...
- 【从0到1,搭建Spring Boot+RESTful API+Shiro+Mybatis+SQLServer权限系统】06、Mybatis+SQLServer集成
1.增加POM依赖 注意pagehelper插件,我重写过,可以到我的这篇文章了解https://www.cnblogs.com/LiveYourLife/p/9176934.html <dep ...
- VMware 虚拟机NAT模式如何设置网络连接,从头到尾全过程~!!
一.首先查看自己的虚拟机服务有没有开启,选择电脑里面的服务查看: 1.计算机点击右键选择管理 2.进入管理选择VM开头的服务如果没有开启的话就右键开启 二.虚拟机服务开启后就查看本地网络虚拟机的网 ...
- java 京东登录
package org.rx.service.media; import io.netty.channel.Channel; import io.netty.handler.codec.http.Ht ...
- 【扩展lucas定理】
洛谷模板题面:https://www.luogu.org/problemnew/show/P4720 扩展卢卡斯被用于解决模数为合数情形下的组合数问题. 首先我们把模数mod质因数分解,解决模每个素数 ...