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 be
extractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10].

我的解答:

  1. def extractEachKth(inputArray, k):
  2. return [i for i in inputArray if i not in inputArray[k - 1::k]]
  1. def extractEachKth(inputArray, k):
  2. del inputArray[k-1::k]
  3. return inputArray

膜拜大佬

Code Signal_练习题_extractEachKth的更多相关文章

  1. Code Signal_练习题_digitDegree

    Let's define digit degree of some positive integer as the number of times we need to replace this nu ...

  2. Code Signal_练习题_Knapsack Light

    You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the ...

  3. Code Signal_练习题_growingPlant

    Each day a plant is growing by upSpeed meters. Each night that plant's height decreases by downSpeed ...

  4. Code Signal_练习题_arrayMaxConsecutiveSum

    Given array of integers, find the maximal possible sum of some of its k consecutive elements. Exampl ...

  5. Code Signal_练习题_differentSymbolsNaive

    Given a string, find the number of different characters in it. Example For s = "cabca", th ...

  6. Code Signal_练习题_firstDigit

    Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int&qu ...

  7. Code Signal_练习题_stringsRearrangement

    Given an array of equal-length strings, check if it is possible to rearrange the strings in such a w ...

  8. 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) + ...

  9. Code Signal_练习题_depositProfit

    You have deposited a specific amount of money into your bank account. Each year your balance increas ...

随机推荐

  1. PHP正则表达式函数的替代函数

    1,preg_split()函数将字符串按照某元素分割,分割后结果以数组方式返回. php中explode()可以实现此功能.array explode(string $pattern,string ...

  2. CSS之浏览器默认样式问题

    今天自己写css样式时,其中用到了<ul>标签,设置了一系列效果后运行,发现位置与设置有出入.chrome上打开检查项,发现<ul>标签的styles底部多了以下一段: ul, ...

  3. Liferay7 BPM门户开发之1:Liferay7开发环境准备

    liferay sdk下载 \IDE下载 \ Tomcat 安装细节不在此赘述 网上有很多. 只讲核心关键坑点 进入2016年,从Liferay6.2.5 ga6版本开始,到7.0 ga3,在ivy环 ...

  4. android stdio Error Could not find com.android.tools common 25.2.2

    Error:Could not find com.android.tools:common:25.2.2. Searched in the following locations: file:/D:/ ...

  5. JAVA面试精选【Java基础第三部分】

    上一篇,我们给出了大概35个题目,都是基础知识,有童鞋反映题目过时了,其实不然,这些是基础中的基础,但是也是必不可少的,面试题目中还是有一些基础题目的,我们本着先易后难的原则,逐渐给出不同级别的题目, ...

  6. Spring Boot + Redis

    启动redis docker run --name redisServer -P -d redis redis自带客户端,启动客户端 docker run -it --link redisServer ...

  7. Android_如何隐藏应用程序的图标

    接下来我要说的这种方法可以隐藏图标,同是也可以正常启动运行. 在manifest的入口activity里面intent-filter中设置<data></data>元素. 比如 ...

  8. 全网最详细的Sublime Text 3的插件官方网站(图文详解)

    不多说,直接上干货! 全网最详细的Windows里下载与安装Sublime Text *(图文详解) 全网最详细的Sublime Text 3的激活(图文详解) 全网最详细的Sublime Text ...

  9. 编写自己的SpringBoot-starter

    前言 我们都知道可以使用SpringBoot快速的开发基于Spring框架的项目.由于围绕SpringBoot存在很多开箱即用的Starter依赖,使得我们在开发业务代码时能够非常方便的.不需要过多关 ...

  10. Linux 各种运算符

    目录 - 算术运算符 - 关系运算符 - 逻辑运算符 - 按位运算符 - 文件测试符 - 算术运算符 算术运算符,常用的有+.-.*./.%.++.--.** + - 加法运算符 [root@www ...