From 88a29c81177fcd9c9af8aa98ffcec0920ec7ff08 Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:05:21 +0530 Subject: [PATCH] Create 1684. Count the Number of Consistent Strings --- 1684. Count the Number of Consistent Strings | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 1684. Count the Number of Consistent Strings diff --git a/1684. Count the Number of Consistent Strings b/1684. Count the Number of Consistent Strings new file mode 100644 index 0000000..5d877ca --- /dev/null +++ b/1684. Count the Number of Consistent Strings @@ -0,0 +1,23 @@ +class Solution { +public: + int countConsistentStrings(string allowed, vector& words) { + set ans; + for (auto it : allowed) { + ans.insert(it); + } + int count = 0; + for (int i = 0; i < words.size(); i++) { + bool f1 = true; + for (auto it : words[i]) { + if (ans.find(it) == ans.end()) { + f1 = false; + break; + } + } + if (f1) { + count++; + } + } + return count; + } +};