mirror of
https://github.com/prdlk/leetcode.git
synced 2026-09-16 23:16:26 +00:00
docs: update documentation structure and examples for Arrays & Strings guide
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
sidebar:
|
||||||
|
icon: circle-question-mark
|
||||||
|
---
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { defineMeta } from "blume";
|
import { defineMeta } from "blume";
|
||||||
|
|
||||||
export default defineMeta({
|
export default defineMeta({
|
||||||
|
title: "Arrays & Strings",
|
||||||
order: 4,
|
order: 4,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ description: 'There are only 6 structural families. Every pattern is a traversal
|
|||||||
sidebar:
|
sidebar:
|
||||||
label: Introduction
|
label: Introduction
|
||||||
order: 1
|
order: 1
|
||||||
icon: code
|
icon: power
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
title: Goals
|
title: Goals
|
||||||
description: Welcome to your new Blume docs.
|
description: Welcome to your new Blume docs.
|
||||||
sidebar:
|
sidebar:
|
||||||
icon: play
|
icon: crosshair
|
||||||
---
|
---
|
||||||
|
|
||||||
## Coding Patterns
|
## Coding Patterns
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* 387. First Unique Character in a String
|
|
||||||
* Difficulty: Easy
|
|
||||||
* https://leetcode.com/problems/first-unique-character-in-a-string/
|
|
||||||
*
|
|
||||||
* ──────────────────────────────────────────────────
|
|
||||||
*
|
|
||||||
* Given a string s, find the first non-repeating character in it and
|
|
||||||
* return its index. If it does not exist, return -1.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Example 1:
|
|
||||||
*
|
|
||||||
* Input: s = "leetcode"
|
|
||||||
*
|
|
||||||
* Output: 0
|
|
||||||
*
|
|
||||||
* Explanation:
|
|
||||||
*
|
|
||||||
* The character 'l' at index 0 is the first character that does not
|
|
||||||
* occur at any other index.
|
|
||||||
*
|
|
||||||
* Example 2:
|
|
||||||
*
|
|
||||||
* Input: s = "loveleetcode"
|
|
||||||
*
|
|
||||||
* Output: 2
|
|
||||||
*
|
|
||||||
* Example 3:
|
|
||||||
*
|
|
||||||
* Input: s = "aabb"
|
|
||||||
*
|
|
||||||
* Output: -1
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Constraints:
|
|
||||||
*
|
|
||||||
* • 1 <= s.length <= 10^5
|
|
||||||
*
|
|
||||||
* • s consists of only lowercase English letters.
|
|
||||||
*/
|
|
||||||
|
|
||||||
func firstUniqChar(s string) int {
|
|
||||||
freq := map[rune]int{}
|
|
||||||
for _, c := range s {
|
|
||||||
freq[c]++
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, c := range s {
|
|
||||||
if freq[c] == 1 {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user