hackerrank Most Common
来源:互联网 发布:淘宝代销不赚钱 编辑:程序博客网 时间:2024/05/22 11:31
题目:https://www.hackerrank.com/challenges/most-commons/problem
题意:按照次数升序,次数相同降序
思路:s = sorted(Counter(input()).items(), key= lambda x: (-x[1],x[0]))[:3]
详细可见python dict sorted 排序
代码:
'''-*- coding: utf-8 -*-@Author : PlayerGuan@Time : 2017/10/14 23:12@Software: PyCharm Community Edition@File : main.py'''from collections import Counters = sorted(Counter(input()).items(), key= lambda x: (-x[1],x[0]))[:3]for x in s: print(x[0]+" "+str(x[1]))
阅读全文
0 0
- hackerrank Most Common
- linux most common use
- The Most Common but Most Imporant Words
- hackerRank
- HackerRank
- HackerRank
- HackerRank
- HackerRank
- HackerRank
- HackerRank
- 【HackerRank】Common Child (LCS)最长公共子序列
- 5 Most Common Web Standards Misconceptions
- The Two Most Common Graphics Algorithms
- Some of the most common web site
- Most common English technical English Papers
- The most common (worst) passwords of 201
- List of the Most Common Data Type Mappings
- The following FAQ answers some of the most common
- Java对象克隆
- 51talk-4 I'm not alone here
- 例子---PHP与Form表单之一
- Oracle12c安装后忘记用户名和密码可通过如下方法解决:
- 将a标签的下划线去掉的方法
- hackerrank Most Common
- 二叉树的遍历
- caioj 练习题 1051高密度加法
- 使用LitePal做一个收藏新闻的功能 + SwipeBackLayout滑出活动
- POJ
- [LeetCode] Longest Substring Without Repeating Characters
- Wikipedia 2017.11.10
- E
- LeetCode刷题记录1-求容器的任意2个元素和某一值的下标