docs(welcome): restructure documentation directories and add new guides section

This commit is contained in:
Prad Nukala committed 2026-07-15 15:07:28 -04:00
1 parent 0a439d468e
commit f4edb09e5e
8 files changed
+19

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
---
title: LC-387
description: First Unique Character in a String
---
## Examples
| Input | Output |
| ---------------- | ------ |
| `"leetcode"` | `0` |
| `"loveleetcode"` | `2` |
| `"aabb"` | `-1` |
## Hints
<Accordion type="single">
<AccordionItem title="Constraints">
Constraints:
• `1 <= s.length <= 10^5`
• `s` consists of only lowercase English letters.
</AccordionItem>
<AccordionItem title="Problem Statement">
Given a string `s`, find the first non-repeating character in it and return its index.
If it does not exist, return `-1`.
</AccordionItem>
</Accordion>
## Solution
```js
/**
* @param {string} s
* @return {number}
*/
var firstUniqChar = function (s) {
// Default for Hammer
const freq = {};
for (let c of s) freq[c] = (freq[c] || 0) + 1;
// Problem Specific
// Loop the ORIGINAL string — we want an index, so no sorting
for (let i = 0; i < s.length; i++) {
if (freq[s[i]] === 1) {
return i;
}
}
return -1;
};
```
+49
View File
@@ -0,0 +1,49 @@
---
title: LC-451
description: Sort Characters By Frequency
---
## Examples
| Input | Output |
| ---------- | -------- |
| `"tree"` | `"eert"` |
| `"cccaaa"` | `"aaaccc"` |
| `"Aabb"` | `"bbAa"` |
## Hints
<Accordion type="single">
<AccordionItem title="Constraints">
Constraints:
• `1 <= s.length <= 5 * 10^5`
• `s` consists of uppercase and lowercase English letters and digits.
</AccordionItem >
<AccordionItem title="Problem Statement">
Given a string `s`, sort it in decreasing order based on the frequency of the characters.
The frequency of a character is the number of times it appears in the string.
Return the sorted string. If there are multiple answers, return any of them.
</AccordionItem >
</Accordion>
## Solution
```js
/**
* @param {string} s
* @return {string}
*/
var frequencySort = function (s) {
// Default for Hammer
const freq = {};
for (let c of s) freq[c] = (freq[c] || 0) + 1;
// Problem Specific
// Sort characters by descending frequency; same chars stay grouped
return s
.split("")
.sort((a, b) => freq[b] - freq[a] || a.localeCompare(b))
.join("");
};
```