Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions md/0038.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
เราสามารถเก็บมุกทั้งหมดที่อ้วนเล่นในอะเรย์ของสตริง โดยรวมมุกซ้ำไปด้วย จากนั้นเราจะเรียงมุกทั้งหมดตามลำดับตัวอักษร และตัดมุกที่ซ้ำทิ้ง ซึ่งสามารถใช้ library ใน STL เช่น
```cpp
sort(note.begin(), note.end());
note.resize(unique(note.begin(), note.end()) - note.begin());
for (auto s: note) cout << s << "\n";
}
```
หรือเขียนเช็คมุกซ้ำเองเช่น
```cpp
sort(note.begin(), note.end());
string last = "";
for (auto s: note) {
if (s == last) continue;
last = s;
cout << s << "\n";
}
}
```