华为机考入门python3--(14)牛客14-字符串排序

分类:列表、排序

知识点:

  1. 字典序排序 sorted(my_list)

题目来自【牛客】

python 复制代码
def sort_strings_by_lex_order(strings):  
    # 使用内置的sorted函数进行排序,默认是按照字典序排序  
    sorted_strings = sorted(strings)  
    # 返回排序后的字符串列表  
    return sorted_strings  


n = int(input().strip())

strings = []
for i in range(n):
    strings.append(input().strip())

sorted_strings = sort_strings_by_lex_order(strings)  

# 输出结果  
for s in sorted_strings:  
    print(s)

by 软件工程小施同学

相关推荐
西柚研究生1234567 小时前
论文分析17:YOLOv11_UAVNet:无人机航拍图像专用目标检测算法
人工智能·python·深度学习·算法·目标检测
昇腾知识体系7 小时前
昇腾 torchrec_npu Docker 镜像选择:CANN/PyTorch/torchrec 版本矩阵与启动参数
人工智能·华为·知识图谱
hetao17338377 小时前
2026-09-17 hetao1733837 的刷题记录
c++·算法
昇腾知识体系8 小时前
K8s 调度昇腾 NPU:device-plugin 部署、Volcano 与 vNPU 切分
人工智能·华为·知识图谱
午彦琳8 小时前
2026.9.17
数据结构·算法·leetcode
木井巳9 小时前
【记忆化搜索】不同路径
java·算法·leetcode·深度优先·剪枝·推荐算法
怕浪猫10 小时前
从 Windows 换到 Mac 三个月,我真香了
算法·面试·架构
菜鸟~noob23310 小时前
【Bonjour】华为Peerium架构深度解析:从冯·诺依曼到百万处理器“一台计算机”,附MATLAB性能仿真【含matlab代码,可直接运行】
开发语言·matlab·华为·peerium
aichitang202410 小时前
前端小skill
前端·人工智能·算法·ai·前端框架
All for pursuit.12 小时前
【链表-9】146.LRU缓存
数据结构·c++·算法·leetcode