From da0d5dcf50f8fa8def91abaafce1fd5624ec1a61 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 8 Jan 2024 19:15:36 +0000 Subject: 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. --- challenge-250/eric-cheung/python/ch-2.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'challenge-250/eric-cheung/python/ch-2.py') 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) -- cgit