当前位置:网站首页>Golden code of programmer interview
Golden code of programmer interview
2022-06-30 05:21:00 【I'm not thin but funny】
Interview questions 01.01. Determine whether the character is unique
Implement an algorithm , Determine a string s Whether all the characters of are different .
Example 1:
Input : s = “leetcode”
Output : false
Example 2:
Input : s = “abc”
Output : true
set Weight removal comparison length
/** * @param {string} astr * @return {boolean} */
var isUnique = function(astr) {
return new Set(astr).size==astr.length
};
Hash thought
/** * @param {string} astr * @return {boolean} */
var isUnique = function(astr) {
let obj = {
}
for (let i of astr) {
if (obj[i]) {
return false
} else {
obj[i] = 1
}
}
return true
}
First and last index Is it consistent
/** * @param {string} astr * @return {boolean} */
var isUnique = function(astr) {
for (let i of astr) {
if (astr.indexOf(i) !== astr.lastIndexOf(i)) {
return false
}
}
return true
}
边栏推荐
- Go Land no tests were Run: FMT cannot be used. Printf () & lt; BUG & gt;
- 2021-07-29 compilation of Cura in ubantu18.04
- 炒美原油的国际交易平台如何能保障资金安全呢?
- Unity profiler performance analysis
- Generate a slice of mesh Foundation
- Responsive flow layout
- Initial environment configuration of the list of OpenGL super classic (version 7) vs2019
- 14x1.5cm竖向标签有点难,VFP调用BarTender来打印
- Unity + hololens publishing settings
- Rotation, translation and scaling of unity VR objects
猜你喜欢

pytorch中常用损失函数总结

VFPBS上传EXCEL并保存MSSQL到数据库中

The minecraft server address cannot be refreshed.

Unity + hololens2 performance test

Access is denied encountered when vfpbs calls excel under IIS

Use the code cloud publicholiday project to determine whether a day is a working day

Unity publishing /build settings

Records of some problems encountered during unity development (continuously updated)

Intellj idea generates jar packages for projects containing external lib to other projects. The method refers to the jar package written by itself

【VCS+Verdi聯合仿真】~ 以計數器為例
随机推荐
Very nervous. What should I do on the first day of software testing?
Records of problems encountered in unity + hololens development
RedisTemplate 常用方法汇总
如何写论文
Operation of JSON file
Force buckle 27 Removing Elements
Revit二次开发---未打开项目使用面板功能
【VCS+Verdi联合仿真】~ 以计数器为例
Ugui uses its own function to realize reverse mask
Unity + hololens publishing settings
Chapter 8 primitive processing of OpenGL super classic (version 7)
ParticleSystem in the official Manual of unity_ Collision module
企事业单位源代码防泄露工作该如何进行
Unity shader flat shadow
Unity C trigonometric function, right triangle corner calculation
[recruitment] UE4 Development Engineer
Another download address for typro
Set a plane to camera viewport
PyGame. Why can't I exit when I click X in the window? I can only exit when I return idle
旋转框目标检测mmrotate v0.3.1入门