【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 ...
随机推荐
- C语言的文件操作
在操作系统中,为了统一对各种硬件的操作,简化接口,不同的硬件设备也被看成一个文件.对于这些文件的操作,等于是对普通文件的操作.例如,通常把显示器称为标准输出文件,printf就是想这个文件输出,把键盘 ...
- HDU-4609(FFT/NTT)
HDU-4609(FFT/NTT) 题意: 给出n个木棒,现从中不重复地选出3根来,求能拼出三角形的概率. 计算合法概率容易出现重复,所以建议计算不合法方案数 枚举选出的最大边是哪条,然后考虑剩下两条 ...
- v-bin:href 绑定链接
<div id="app06"> <a v-bind:href="URL">我是百度</a> </div> 调用 ...
- 常用js校验
身份证 function isCardNo(idCard){ //15位和18位身份证号码的正则表达式 var regIdCard=/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0 ...
- webpack 导出、导入模块(及路径)
参考:https://blog.csdn.net/xyphf/article/details/83411552 (下面的代码亲测有效) 注:导入的模块的方法,只有两种方法 import 和 requ ...
- UIDatePicker odd behavior when setting minuteInterval
http://stackoverflow.com/questions/6948297/uidatepicker-odd-behavior-when-setting-minuteinterval Her ...
- Django实现得步骤流程
我们利用django实现功能得时候,步骤和流程是怎样得呢? 一,首先要在Models中创建表. 1,在setting中找到DATABASE 中找到要使用得数据库,用mysql就把名字改了mysql. ...
- Nacos Config客户端与Spring Boot、Spring Cloud深度集成
目录 Nacos与Spring Boot集成 @NacosPropertySource和@NacosValue com.alibaba.nacos.spring.core.env.NacosPrope ...
- flask-sqlalchemy报错 Object '<User at xxxx>' is already attached to session '1' (this is '2')
报错: Object '<User at xxxx>' is already attached to session '1' (this is '2') 结论: 两个不同的db ...
- 阿里云epel源
epel是个好东西,不过国外的速度实在是不能忍受.所以 有了这篇文章.1. 首先卸载以前装的epel以免影响 rpm -e epel-release 2. 下载阿里提供的epel wget -P /e ...