列表

详情


FED76. 检查重复字符串

描述

给定字符串 str,检查其是否包含连续重复的字母(a-zA-Z),包含返回 true,否则返回 false

示例1

输入:

'rattler'

输出:

true

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 863ms, 内存消耗: 77824KB, 提交时间: 2020-12-29

{"css":"","js":"function containsRepeatingLetter(str) {\n    if(str == '' || str == undefined || str.length == 1) {\n        return false;\n    }\n    \n    let bool = false;\n    for(let i = 0; i < str.length;i++) {\n        if((str[i] == str[i+1] && (!/^\\d+$/.test(str[i])) && (!/^\\d+$/.test(str[i+1])))) {\n            bool = true;\n            break;\n        }\n    }\n    return bool;\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 867ms, 内存消耗: 77900KB, 提交时间: 2020-12-28

{"css":"","js":"function containsRepeatingLetter(str) {\n    return /([a-zA-Z])\\1/.test(str)\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 871ms, 内存消耗: 77996KB, 提交时间: 2020-11-23

{"css":"","js":"function containsRepeatingLetter(str) {\n    var reg = /([a-zA-Z])\\1/;\n    return reg.test(str);\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 872ms, 内存消耗: 77776KB, 提交时间: 2020-12-28

{"css":"","js":"function containsRepeatingLetter(str) {\n    return (/([a-zA-Z])\\1/).test(str)\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 874ms, 内存消耗: 77872KB, 提交时间: 2020-12-25

{"css":"","js":"function containsRepeatingLetter(str) {\n    return /([a-zA-Z])\\1/.test(str)\n}","html":"","libs":[]}

上一题