【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 ...
随机推荐
- PID算法知识点博文收藏记录
https://blog.csdn.net/Uncle_GUO/article/details/51367764 https://blog.csdn.net/HandsomeHong/article/ ...
- jcrop+java 后台
//jcrop 用法 lpf //页面引入 //<link rel="stylesheet" href="${basePath}/scripts/jcrop/jqu ...
- range类型(Python)
range 不是 iterator >>> R = range(3) >>> next(R) Traceback (most recent call last): ...
- docker 运行jenkins及vue项目与springboot项目(二.docker运行jenkins为自动打包运行做准备)
docker 运行jenkins及vue项目与springboot项目: 一.安装docker 二.docker运行jenkins为自动打包运行做准备 三.jenkins的使用及自动打包vue项目 四 ...
- JDK 9 发布仅数月,为何在生产环境中却频遭嫌弃?
千呼万唤始出来,在经历了整整一年的跳票之后,Java 9 终于在 9 月 21 日拨开云雾,露出真正的面目.对众多 Java 程序员来说,这一天无疑是一个重大的日子,首先 Java 开发者们再也不用羡 ...
- Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错
做模糊搜索时,出现了 bind or column index out of range: handle 0x2fb180 报错 public Cursor getTitle(String word ...
- Alpha冲刺阶段博客目录
Alpha冲刺阶段博客目录 Scrum Meeting 时间 链接 内容 第六周 https://www.cnblogs.com/error0/p/11815255.html 需求分析 第七周 htt ...
- objective-c: Functions and static keyword
Functions function is a concept for C programming language, objective-c is entirely relies on C. To ...
- HTML中多媒体标签技术说明
在纯文本的HTML页面中加入图片,给原来单调乏味的页面添加生气.HTML语言中利用<IMG>标记插入图片. 1.图片标记<IMG>及其属性 在网站上,网页设计者都使用了大量精心 ...
- js、jQuery实现文字上下无缝轮播、滚动效果
因项目需要实现消息通知上下无缝轮播的效果,所以写了一下,在这个分享出来,希望再次遇到此需求的道友,可以直接拷贝来用,节约一点不必要的时间. 原生JS版本 <!DOCTYPE html> & ...