图片
This commit is contained in:
@@ -140,12 +140,30 @@ export default {
|
||||
confirm() {
|
||||
uni.navigateTo({url: './result'})
|
||||
},
|
||||
|
||||
/*
|
||||
给定一个字符串 s ,找到 它的第一个不重复的字符,并返回它的索引 。如果不存在,则返回 -1 。
|
||||
s = "leetcode" . => 0
|
||||
s = "loveleetcode" => 2
|
||||
*/
|
||||
firstUniqChar(str) {
|
||||
for(let i=0; i<=str.length; i++) {
|
||||
// let sum = 0;
|
||||
for(let x=0;x<str.length;x++) {
|
||||
if(str[i] === str[x] && i!=x) {
|
||||
console.log(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return -1
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
this.current ++;
|
||||
},
|
||||
onLoad() {
|
||||
// this.createdTime = Date.parse(new Date())
|
||||
this.firstUniqChar('leetcode')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user