diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-08 19:15:36 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-08 19:15:36 +0000 |
| commit | da0d5dcf50f8fa8def91abaafce1fd5624ec1a61 (patch) | |
| tree | 48d62d167588ce05b7ad7e5e2b321355d81a3f0f /challenge-250/eric-cheung/python/ch-2.py | |
| parent | 066a38cc3004d179463b4c3cd5feb18b042ad36f (diff) | |
| download | perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.gz perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.bz2 perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.zip | |
i- Added solutions by Mark Anderson.
- Added solutions by PokGoPun.
- Added solutions by Simon Proctor.
- Added solutions by Luca Ferrari.
- Added solutions by Thomas Kohler.
- Added solutions by Peter Campbell Smith.
- Added solutions by Niels van Dijke.
- Added solutions by W. Luis Mochan.
- Added solutions by David Ferrone.
- Added solutions by Dave Jacoby.
- Added solutions by Peter Meszaros.
- Added solutions by Laurent Rosenfeld.
Diffstat (limited to 'challenge-250/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-250/eric-cheung/python/ch-2.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/challenge-250/eric-cheung/python/ch-2.py b/challenge-250/eric-cheung/python/ch-2.py index 43a7617ff9..a659fab6a6 100755 --- a/challenge-250/eric-cheung/python/ch-2.py +++ b/challenge-250/eric-cheung/python/ch-2.py @@ -1,9 +1,13 @@ -def GetAlphaNumLen (strInput):
- return int(strInput) if strInput.isnumeric() else len(strInput)
+## Remarks
+## https://github.com/doocs/leetcode/blob/main/solution/1300-1399/1380.Lucky%20Numbers%20in%20a%20Matrix/README_EN.md
-## arrAlphaNumStr = ["perl", "2", "000", "python", "r4ku"] ## Example 1
-arrAlphaNumStr = ["001", "1", "000", "0001"] ## Example 2
+## arrMatrix = [[3, 7, 8], [9, 11, 13], [15, 16, 17]] ## Example 1
+## arrMatrix = [[1, 10, 4, 2], [9, 3, 8, 7], [15, 16, 17, 12]] ## Example 2
+arrMatrix = [[7, 8], [1, 2]] ## Example 3
-arrOutput = [GetAlphaNumLen(strLoop) for strLoop in arrAlphaNumStr]
-print (max(arrOutput))
+setRowMin = {min(rowLoop) for rowLoop in arrMatrix}
+setColMax = {max(colLoop) for colLoop in zip(*arrMatrix)}
+
+arrLuckyNum = list(setRowMin & setColMax) ## Intersection of Two Sets
+print (arrLuckyNum if len(arrLuckyNum) > 0 else -1)
|
