Skip to content

Create 387. First Unique Character in a String.md - #10

Open
mt2324 wants to merge 1 commit into
mainfrom
387.-First-Unique-Character-in-a-String
Open

mt2324 wants to merge 1 commit into
mainfrom
387.-First-Unique-Character-in-a-String

Conversation

@mt2324

@mt2324 mt2324 commented Sep 10, 2026

Copy link
Copy Markdown
Owner

No description provided.

@huyfififi huyfififi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

```

## STEP 2
Linked Hashmapを使っても解けるみたい。順序を保持するhashmapに今の所1回しか登場していない文字と場所を記録し、すでに出現した文字をhashsetに記録する。2回目が現れたらhashmapから消して、最後にhashmapの中で一番最近のものを取得する。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: dict の挿入順が保持されることを利用しているのですね。一番最近のものを取得というより、最初に挿入されたものを取得、とした方が誤解がないかもしれません。

カウンターで頻度を取っておいて、次は先頭から頻度が1のものを探す。
```python
from collections import Counter
class Solution:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PEP8

Surround top-level function and class definitions with two blank lines.

とあるように、class と import 文の間に2つ空行を入れる方が一般的かと思います。

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