From e24be322983f71a11b9c0bdd52d288fed04cbe11 Mon Sep 17 00:00:00 2001 From: "k.Balaji" <66003194+balubalaji3002@users.noreply.github.com> Date: Fri, 24 Mar 2023 15:47:21 +0530 Subject: [PATCH 1/2] Create DeleteandEarn.py --- Leetcode Challenge/March/Python/DeleteandEarn.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Leetcode Challenge/March/Python/DeleteandEarn.py diff --git a/Leetcode Challenge/March/Python/DeleteandEarn.py b/Leetcode Challenge/March/Python/DeleteandEarn.py new file mode 100644 index 0000000..f8f2db6 --- /dev/null +++ b/Leetcode Challenge/March/Python/DeleteandEarn.py @@ -0,0 +1,14 @@ +def deleteAndEarn(self, nums: List[int]) -> int: + n = 10001 + values=[0]*n + for num in nums: + values[num] += num + take = 0 + skip = 0 + for i in range(n): + takei = skip + values[i] + skipi = max(skip, take) + take = takei + skip = skipi + + return max(take, skip) From 8a8c0481069692cb1955cffe27006da6d1265ed0 Mon Sep 17 00:00:00 2001 From: "k.Balaji" <66003194+balubalaji3002@users.noreply.github.com> Date: Sat, 13 May 2023 23:56:01 +0530 Subject: [PATCH 2/2] Create KMP Algorithm for Pattern Searching.py --- .../KMP Algorithm for Pattern Searching.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Strings/KMP Algorithm for Pattern Searching.py diff --git a/Strings/KMP Algorithm for Pattern Searching.py b/Strings/KMP Algorithm for Pattern Searching.py new file mode 100644 index 0000000..997b834 --- /dev/null +++ b/Strings/KMP Algorithm for Pattern Searching.py @@ -0,0 +1,43 @@ +pattern='balu' +text='this is balaji balu' + + +def lps(): + n=len(pattern) + i=1 + j=0 + + while i