aboutsummaryrefslogtreecommitdiff
path: root/number_senior_citizen.py
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2024-07-31 18:52:20 -0600
committerJack Sangdahl <[email protected]>2024-07-31 18:52:20 -0600
commit801d7b66811d0c554c1a9cfa174610807c97609f (patch)
tree9980c933ff416ec0956c98c761baf7f6e891ab9d /number_senior_citizen.py
parent16394856bc7b185e1cc92fe32797e68ba82d6cf6 (diff)
downloadleetcode-801d7b66811d0c554c1a9cfa174610807c97609f.tar.gz
leetcode-801d7b66811d0c554c1a9cfa174610807c97609f.zip
2678. number of senior citizens
Diffstat (limited to 'number_senior_citizen.py')
-rw-r--r--number_senior_citizen.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/number_senior_citizen.py b/number_senior_citizen.py
new file mode 100644
index 0000000..20194e8
--- /dev/null
+++ b/number_senior_citizen.py
@@ -0,0 +1,31 @@
+# 2678. Number of Senior Citizens
+
+"""
+you are given a 0-indexed array of strings 'details'. each element of
+'details' provides information about a given passenger compressed into a
+string of length '15'. the system is such that the first ten characters of
+the phone number of passengers, the next character denotes the gender of the
+person, the following two characters are used to indicate the age of the
+person, and the last two characters determine the seat allotted to that
+person. return the number of passengers who are strictly more than 60 years
+old
+"""
+
+
+class Solution(object):
+ def countSeniors(self, details):
+ """
+ :type details: List[str]
+ :rtype: int
+ """
+ return sum(int(p[-4:-2]) > 60 for p in details)
+
+
+if __name__ == "__main__":
+ obj = Solution()
+ print(
+ obj.countSeniors(
+ details=["7868190130M7522", "5303914400F9211", "9273338290F4010"]
+ )
+ )
+ print(obj.countSeniors(details=["1313579440F2036", "2921522980M5644"]))