当前位置:网站首页>1961 check if string is a prefix of array
1961 check if string is a prefix of array
2022-06-22 12:35:00 【Zhou xiansen likes vegetarian food】
This series is a new pit opened out of personal interest , Recently I saw my classmates brush LeetCode Algorithm problem , Just want to write those that can be one line Python The title of the code , Therefore, the efficiency of problem-solving methods in this column is not guaranteed , Only for pursuit “ The romance of one line ”.
subject

Answer key
Explain the subject briefly , Given a string s, And a list of strings words, solve s Whether it is words Prefix string ( namely words In front of k Whether or not one can form s). The difficulty of this question is Easy.
Code
The train of thought of this question is relatively simple , Cumulative direct violence against words Before k Splices , See if there is a former k The splicing result of is equal to s, If there is such a k, The output true, Otherwise output false.
class Solution:
def isPrefixString(self, s: str, words: List[str]) -> bool:
return sum(map(lambda x: x == s, [''.join(words[:i+1]) for i in range(len(words))])) > 0
The feedback submitted is as follows .
边栏推荐
- TIS教程01-安装
- EndeavourOS安装配置全攻略!
- V4L2像素格式及其对应的含义
- Error: unresolved variable $bus and "typeerror: cannot read property '$on' of undefined“
- Difference between function pointer and pointer function
- Flutter——实现网易云音乐的Tabbar切换效果
- Démarrer avec l'animation flutter: animation de chargement des anneaux intérieurs et extérieurs inversés
- SQL函数——将一对多关系转换成一对一关系
- V4l2 pixel format and its corresponding meaning
- Flutter——实现网易云音乐的渐进式卡片切换
猜你喜欢

翻译soem的 tutorial.txt 文件

Flutter——实现网易云音乐的渐进式卡片切换

Flutter:剥离StatefulWidget——简化页面开发、跳转以及传值

0007-Reverse Integer(整数反转)

Vue混写Minxin、虚拟Dom/ref、动态组件、缓存keep

Getting started with webrtc: 11 In kurento, rtendpoint is used to pull RTP streams for clustering in live broadcast

Machine learning and deep learning - activation function (to be continued)

Flutter混合开发练习——Evenet&Method Channel协作加载大图

Fluent: split statefulwidget -- simplify page development, jump and value transfer

Flutter -- realize the tabbar switching effect of Netease cloud music
随机推荐
ffmpeg将amr格式转成mp3格式
What is C language structure byte alignment and why?
getenv、setenv函数(获取和设置系统环境变量) 与 环境变量
Flutter——实现网易云音乐的渐进式卡片切换
TIS教程04-客户端
自动删除指定目录、指定时间内的日志文件
Sap-abap- how to open a local file
Endeavouros installation configuration introduction!
增长知识网
Invisible traffic Commander: on Urban Rail Transit Signal System
Error: unresolved variable $bus and "typeerror: cannot read property '$on' of undefined“
仿网易云音乐的滑动冲突处理效果
请问Flink的动态表是这样创建吗?我用flink cdc 读mysql数据,写flink动态表,发
运行sqoop1.4.5报Warning: does not exist! HCatalog jobs will fail.
stm32 hal串口中断分析
Es aggregation details
TiFlash 函数下推必知必会丨十分钟成为 TiFlash Contributor
Reddit产品主管:为Web3创作者准备的NFT会员实用指南
Flutter's custompaint drawing Bezier curve chart (III)
Flutter&Flame——TankCombat游戏手柄开发(一)