Skip to content

3 longest substring without repeating characters#48

Open
dxxsxsxkx wants to merge 2 commits into776_split_bstfrom
3_longest_substring_without_repeating_characters
Open

3 longest substring without repeating characters#48
dxxsxsxkx wants to merge 2 commits into776_split_bstfrom
3_longest_substring_without_repeating_characters

Conversation

@dxxsxsxkx
Copy link
Copy Markdown
Owner

@dxxsxsxkx dxxsxsxkx commented Mar 18, 2026

int max_length = 0;

for (int right = 0; right < s.size(); ++right) {
while (characters.contains(s[right])) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

countよりcontainsの方が分かりやすいですね。細かいところも改善されていて素晴らしいと思いました。

class Solution {
public:
int lengthOfLongestSubstring(std::string s) {
std::unordered_set<char> characters;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この短さなら問題ないのですが、どちらかというと character というより seen のような情報を名前に乗せたいと思いました。character なのは <char> で分かりますし。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants