Code Signal_练习题_differentSymbolsNaive
Given a string, find the number of different characters in it.
Example
For s = "cabca", the output should bedifferentSymbolsNaive(s) = 3.
There are 3 different characters a, b and c.
我的解答:
def differentSymbolsNaive(s):
return len(set(s))
一模一样
膜拜大佬
Code Signal_练习题_differentSymbolsNaive的更多相关文章
- 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_练习题_firstDigit
Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int&qu ...
- Code Signal_练习题_extractEachKth
Given array of integers, remove each kth element from it. Example For inputArray = [1, 2, 3, 4, 5, 6 ...
- 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 ...
随机推荐
- Sublime Text3 实现在浏览器中以HTML格式预览md文件
1.首先找到Package Control 打开Sublime Text3,找到菜单栏:Preferences → Package Control,没有找到Package Control,那么点击Pa ...
- Android v7包下Toolbar和ActionBarActivity实现后退导航效果
android.support.v7包下的ToolBar和ActionBarActivity,均自带后退导航按钮,只是要手动开启,让它显示出来.先来看看ToolBar,页面前台代码: <andr ...
- Orleans实战目录
一 项目结构 1> 接口项目 .net core类库 2> Grains实现项目 .net core类库 3> 服务Host .net core console applicatio ...
- PEP_2007相关问题记录
1.在C++中,int main(int argc, char** argv)中的参数是什么意思? 其中,第一个argc是输入的参数的个数,第二个argv可以理解为一个数组,我们可以通过argv来打印 ...
- vector源码2(参考STL源码--侯捷):空间分配、push_back
vector源码1(参考STL源码--侯捷) vector源码2(参考STL源码--侯捷) vector源码(参考STL源码--侯捷)-----空间分配导致迭代器失效 vector源码3(参考STL源 ...
- JAVA面试精选【Java算法与编程一】
在面试中,算法题目是必须的,通过算法能够看出一个程序员的编程思维,考察对复杂问题的设计与分析能力,对问题的严谨性都能够体现出来.算法是一系列解决问题的清晰指令,也就是说,能够对一定规范的输入,在有限时 ...
- Resolve类中错误体系的处理
标红的表示要走3步骤,也就是: final List<MethodResolutionPhase> methodResolutionSteps = List.of( MethodResol ...
- java工具类-日期工具类
1.获得时间戳 为了统一其他语言的如php和unix系统获取的时间戳是10位长度的,精确到秒. java时间戳长度是13位,精确到毫秒 我们获取时间戳需要相应处理. //获取当前时间戳,除以1000, ...
- Maven 入门——Maven 的安装和配置
1.安装 Windows 环境 Maven 官网下载安装文件 解压到指定目录 配置环境变量(M2_HOME) cmd 输入 mvn -v Mac环境 brew install maven 配置环境变量 ...
- es6学习笔记1
最近在阅读<探索es6>,就把自己认为重要的做一点笔记,方便日后学习. 1.获取更多的es6资源的办法 有两组 ES6 资源: “ ECMAScript 6 Tools ”,作者 Addy ...