From 771cc78b2086ae2cf6b07c9a5cbc56c1f336eb5f Mon Sep 17 00:00:00 2001 From: vzsky Date: Wed, 13 Aug 2025 17:49:03 +0700 Subject: [PATCH] Add 0038 --- md/0038.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 md/0038.md diff --git a/md/0038.md b/md/0038.md new file mode 100644 index 0000000..7579a94 --- /dev/null +++ b/md/0038.md @@ -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"; + } +} +```