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 ...
随机推荐
- 栈(链式栈)----C语言
链式栈:就是一种操作受限的单向链表,对单向链表还不了解的可先看一下之前的一篇关于单向链表的随笔,链表(单向链表的建立.删除.插入.打印),理解了单向链表后再来看链式栈就比较轻松了 链式栈的操作一般含有 ...
- css居中小结
从css入门就开始接触,无所不在的,一直备受争议的居中问题. css居中分为水平居中和垂直居中,水平居中方式也较为常见和统一,垂直居中的方法就千奇百怪了. 博客原文地址:Claiyre的个人博客 ht ...
- 在ubuntu中我们使用sudo apt-get install 或者dpkg -i *.deb安装软件时,常常提示“有未能满足的依赖关系“,解决方法
很早之前在ubuntu安装软件时遇到的问题,今天打开ubuntu看到了,总结如下: 在ubuntu中我们使用sudo apt-get install 或者dpkg -i *.deb安装软件常常提示“有 ...
- 如何在vue中全局引入stylus文件的公共变量
新建 一个公共的stylus公共文件添加公共变量,如下: 修改下图圈出的文件: 具体的修改如下: // generate loader string to be used with extract t ...
- 将celery定时任务设置为根据本地时区触发
默认celery的时区为UTC,如果要在django项目中将celery定时任务配置为根据本地时区触发,则需要修改 在setttings.py 添加以下任意一行: # celery 相关配置 CELE ...
- [Leetcode]931.下降路径最小和
题目链接 这一题目首先需要弄懂题目的意思,下降路径最小和指的是在方阵中可以从上往下行走,走过后获得的值最小,方向可以是走左下,右下,直下. 题目和传统的动态规划一样,把边界的值先初始化,然后通过状态转 ...
- 多条记录的同一字段组合成一个字符串 FOR XML PATH
stuff(select ',' + fieldname from tablename for xml path('')),1,1,'') 这一整句的作用是将多行fieldname字段的内容串联起来, ...
- Python 模块 和 包
模块 os模块 路径拼接 os.path.join
- C# 算法系列一基本数据结构
一.简介 作为一个程序员,算法是一个永远都绕不过去的话题,虽然在大学里参加过ACM的比赛,没记错的话,浙江赛区倒数第二,后来不知怎么的,就不在Care他了,但是现在后悔了,非常的后悔!!!如果当时好好 ...
- python垃圾回收
python垃圾回收 python垃圾回收主要使用引用计数来跟踪和回收垃圾.在引用计数的基础上,通过“标记—清除”解决容器对象可能产生的循环引用问题,通过“分代回收”以空间换时间的方法提高垃圾回收效率 ...