当前位置:网站首页>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
}
边栏推荐
- Summary of common loss functions in pytorch
- Detailed explanation of the loss module of mmdet
- 旋转框目标检测mmrotate v0.3.1 训练DOTA数据集(二)
- Unity publishing /build settings
- Unity multiple UI page turning left and right
- [typescript] cannot redeclare block range variables
- Unity supports the platform # define instruction of script
- Introduction to mmcv common APIs
- ParticleSystem in the official Manual of unity_ Collision module
- Force buckle 27 Removing Elements
猜你喜欢
Unity2019.3.8f1 development environment configuration of hololens2
【LeetCode】Easy | 232. Using stack to realize queue (pure C manual tearing stack)
Intellj idea jars projects containing external lib to other project reference methods - jars
Rotation, translation and scaling of unity VR objects
Unity packaging and publishing webgl error reason exception: failed building webgl player
East Tower attack and defense world - XSS bypasses the safety dog
Generate a slice of mesh Foundation
[note] usage model tree of the unity resource tree structure virtualizingtreeview
【VCS+Verdi联合仿真】~ 以计数器为例
Bev instance prediction based on monocular camera (iccv 2021)
随机推荐
Unity supports the platform # define instruction of script
pytorch中常用损失函数总结
The minecraft server address cannot be refreshed.
GoLand No Tests Were Run : 不能使用 fmt.Printf() <BUG>
Super comprehensive summary | related improvement codes of orb-slam2 / orb-slam3!
Remote sensing image /uda:curriculum style local to global adaptation for cross domain remote sensing image segmentation
unity 扫描圈 圆扩展方法
Unity notes_ SQL Function
【LeetCode】Easy | 232. Using stack to realize queue (pure C manual tearing stack)
Unity dotween plug-in description
Records of problems encountered in unity + hololens development
Connect() and disconnect() of socket in C #
3D rotation album
Assembly learning tutorial: accessing memory (3)
[note] usage model tree of the unity resource tree structure virtualizingtreeview
Unity 3D model operation and UI conflict Scrollview
Responding with flow layout
Fifty years ago, the go code first submitted by the inventor of Hello world was as long as this
Unity call Exe program
C # three ways to obtain web page content