当前位置:网站首页>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
}
边栏推荐
- Expansion method of unity scanning circle
- Force buckle 704 Binary search
- Set a plane to camera viewport
- Introduction to mmcv common APIs
- Virtual and pure virtual destructions
- 《谁动了我的奶酪》读后感
- Unit asynchronous jump progress
- Connect() and disconnect() of socket in C #
- [learning notes] AssetBundle, xlua, hot update (use steps)
- Revit二次開發---未打開項目使用面板功能
猜你喜欢

Terminal convenient SSH connection

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

Intellj idea jars projects containing external lib to other project reference methods - jars

使用码云PublicHoliday项目判断某天是否为工作日

【VCS+Verdi联合仿真】~ 以计数器为例
![[typescript] cannot redeclare block range variables](/img/52/2fd3071ca9e3c5023c6b65961e2cf7.jpg)
[typescript] cannot redeclare block range variables

中文版PyCharm改为英文版PyCharm

Pytorch的安装以及入门使用

遥感图像/UDA:Curriculum-Style Local-to-Global Adaptation for Cross-Domain Remote Sensing Image Segmentat

Network communication problem locating steps
随机推荐
Expansion method of unity scanning circle
mmdet之Loss模块详解
中文版PyCharm改为英文版PyCharm
Initial environment configuration of the list of OpenGL super classic (version 7) vs2019
[notes] unity Scrollview button page turning
Nestjs入门和环境搭建
Use the code cloud publicholiday project to determine whether a day is a working day
Force buckle 209 Minimum length subarray
VFPBS在IIS下调用EXCEL遇到的Access is denied
【LeetCode】Easy | 225. Using queue to realize stack (pure C manual tearing queue)
图扑软件基于钻孔数据的三维地质模型可视化
Unity + hololens2 performance test
MinGW-w64下载文件失败the file has been downloaded incorrectly!
Unity Catmull ROM curve
Untiy3d controls scene screenshots through external JSON files
Nestjs introduction and environment construction
Pyinstaller flash back
Detailed explanation of sorting sort method of JS array
很紧张,第一天做软件测试,需要做什么?
Rotation, translation and scaling of unity VR objects