Code Signal_练习题_extractEachKth
Given array of integers, remove each kth
element from it.
Example
For inputArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
and k = 3
, the output should beextractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10]
.
我的解答:
def extractEachKth(inputArray, k):
return [i for i in inputArray if i not in inputArray[k - 1::k]]
def extractEachKth(inputArray, k):
del inputArray[k-1::k]
return inputArray
膜拜大佬
Code Signal_练习题_extractEachKth的更多相关文章
- Code Signal_练习题_digitDegree
Let's define digit degree of some positive integer as the number of times we need to replace this nu ...
- Code Signal_练习题_Knapsack Light
You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the ...
- Code Signal_练习题_growingPlant
Each day a plant is growing by upSpeed meters. Each night that plant's height decreases by downSpeed ...
- Code Signal_练习题_arrayMaxConsecutiveSum
Given array of integers, find the maximal possible sum of some of its k consecutive elements. Exampl ...
- Code Signal_练习题_differentSymbolsNaive
Given a string, find the number of different characters in it. Example For s = "cabca", th ...
- Code Signal_练习题_firstDigit
Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int&qu ...
- Code Signal_练习题_stringsRearrangement
Given an array of equal-length strings, check if it is possible to rearrange the strings in such a w ...
- Code Signal_练习题_absoluteValuesSumMinimization
Given a sorted array of integers a, find an integer x from a such that the value of abs(a[0] - x) + ...
- Code Signal_练习题_depositProfit
You have deposited a specific amount of money into your bank account. Each year your balance increas ...
随机推荐
- 18_python_类关系
一.类与类之间的关系 1.依赖关系 class Elephant: def __init__(self, name): self.name = name def open(self, ...
- 带你走进二进制-一次APT攻击分析
原文:https://osandamalith.com/2017/06/04/apt-attack-in-bangladesh/ 由prison翻译整理,首发i春秋 引言; 这是一次来自遥远国 ...
- 阿里云mysql数据库备份还原
1.下载备份包 在rds的备份恢复中点击下载,在弹出的窗口中复制内网下载地址(前提是目标服务器与rds内网互通,否则请复制外网地址) 在目标服务器中执行如下命令进行下载: wget -c '复制的地址 ...
- falcon适配ldap密码同步
问题 小米的openfalcon在使用ldap首次登陆成功后,会在本地创建同名的账号, 这就有个问题当你更新了ldap的密码时,openfalcon是没有同步本地账号密码的功能 二次改造 方便我们de ...
- 机器学习基石笔记:16 Three Learning Principles
三个理论上界: 三个线性模型: 三个关键工具: 三条学习规则: 1.奥卡姆剃刀定律 先从简单模型开始, 训练后出现欠拟合, 再尝试复杂点模型. 2.采样误差 训练.验证.测试数据尽量同分布. 3.数据 ...
- 使用Nginx转发TCP/UDP数据
编译安装Nginx 从1.9.0开始,nginx就支持对TCP的转发,而到了1.9.13时,UDP转发也支持了.提供此功能的模块为ngx_stream_core.不过Nginx默认没有开启此模块,所以 ...
- xamarin android 需要获取apk签名工具
请打开vs 扩展 搜索 android keystore signature tool 如果是Release 记得查找对应的keystore 文件然后进行获取签名
- Eclipse的使用与Oblect类的常用方法_DAY11
一.Java开发工具的使用 A:notepad windows自带的记事本. B:高级记事本 Editplus Notepad++ UE sublime2 C:集成开发工具(IDE) 开发和运行. E ...
- python多线程-Semaphore(信号对象)
Semaphore(value=1) Semaphore对象内部管理一个计数器,该计数器由每个acquire()调用递减,并由每个release()调用递增.计数器永远不会低于零,当acquire() ...
- Nginx单向认证的安装配置
Nginx单向认证的安装配置 首先系统要已经安装了openssl,以下是使用openssl安装配置单向认证的执行步骤与脚本: #------------------------------------ ...