diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2024-06-27 22:41:06 +0200 | 
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2024-06-27 22:41:06 +0200 | 
| commit | 49357616859faaf9e53468ce71d6cd99bda4fb4a (patch) | |
| tree | d861f4962fce25638a348f81609562b85ec18174 /progs | |
| parent | d653d3598d71fea30d45d118e3d046a3aed53ac1 (diff) | |
Restore progs folder
Diffstat (limited to 'progs')
| -rw-r--r-- | progs/a284.py | 8 | ||||
| -rw-r--r-- | progs/a339.py | 5 | ||||
| -rw-r--r-- | progs/a394.py | 2 | ||||
| -rw-r--r-- | progs/a403.py | 2 | ||||
| -rw-r--r-- | progs/a52.py | 4 | ||||
| -rw-r--r-- | progs/a641.py | 8 | ||||
| -rw-r--r-- | progs/a679.py | 2 | ||||
| -rw-r--r-- | progs/a745.py | 2 | ||||
| -rw-r--r-- | progs/test.py | 17 | ||||
| -rw-r--r-- | progs/test2.py | 3 | 
10 files changed, 34 insertions, 19 deletions
| diff --git a/progs/a284.py b/progs/a284.py index 41d2914..b69395b 100644 --- a/progs/a284.py +++ b/progs/a284.py @@ -1,11 +1,11 @@ -def is_Isomorphic(str1, str2):
 +def is_Isomorphic(str1,str2):          
      dict_str1 = {}
      dict_str2 = {}
      for i, value in enumerate(str1):
 -        dict_str1[value] = dict_str1.get(value, []) + [i]
 +        dict_str1[value] = dict_str1.get(value,[]) + [i]        
      for j, value in enumerate(str2):
 -        dict_str2[value] = dict_str2.get(value, []) + [j]
 +        dict_str2[value] = dict_str2.get(value,[]) + [j]
      if sorted(dict_str1.values()) == sorted(dict_str2.values()):
          return True
      else:
 -        return False
 +        return False
\ No newline at end of file diff --git a/progs/a339.py b/progs/a339.py index 53fcb7e..9a57403 100644 --- a/progs/a339.py +++ b/progs/a339.py @@ -1,5 +1,5 @@  def heap_sort(arr):
 -    heapify(arr)
 +    heapify(arr)  
      end = len(arr) - 1
      while end > 0:
          arr[end], arr[0] = arr[0], arr[end]
 @@ -7,14 +7,11 @@ def heap_sort(arr):          end -= 1
      return arr
 -
  def heapify(arr):
      start = len(arr) // 2
      while start >= 0:
          shift_down(arr, start, len(arr) - 1)
          start -= 1
 -
 -
  def shift_down(arr, start, end):
      root = start
      while root * 2 + 1 <= end:
 diff --git a/progs/a394.py b/progs/a394.py index d977184..4fe6e47 100644 --- a/progs/a394.py +++ b/progs/a394.py @@ -19,4 +19,4 @@ def func(nums, k):      while temp:
          v, key = heapq.heappop(temp)
          result.append(key)
 -    return result
 +    return result
\ No newline at end of file diff --git a/progs/a403.py b/progs/a403.py index ee1bdd7..18c84b2 100644 --- a/progs/a403.py +++ b/progs/a403.py @@ -2,4 +2,4 @@ from collections import Counter  from itertools import chain
  def freq_element(nums):
    result = Counter(chain.from_iterable(nums))
 -  return result
 +  return result
\ No newline at end of file diff --git a/progs/a52.py b/progs/a52.py index 131af01..4a0b33a 100644 --- a/progs/a52.py +++ b/progs/a52.py @@ -1,8 +1,6 @@  from collections import defaultdict
 -
 -
  def grouping_dictionary(l):
      d = defaultdict(list)
      for k, v in l:
          d[k].append(v)
 -    return d
 +    return d
\ No newline at end of file diff --git a/progs/a641.py b/progs/a641.py index 1b7e4bb..51393cd 100644 --- a/progs/a641.py +++ b/progs/a641.py @@ -1,5 +1,5 @@  def count_first_elements(test_tup):
 -    for count, ele in enumerate(test_tup):
 -        if isinstance(ele, tuple):
 -            break
 -    return count
 +  for count, ele in enumerate(test_tup):
 +    if isinstance(ele, tuple):
 +      break
 +  return (count) 
\ No newline at end of file diff --git a/progs/a679.py b/progs/a679.py index 6f1d11c..97472a6 100644 --- a/progs/a679.py +++ b/progs/a679.py @@ -10,4 +10,4 @@ def find_last_occurrence(A, x):              right = mid - 1
          else:
              left = mid + 1
 -    return result 
 +    return result 
\ No newline at end of file diff --git a/progs/a745.py b/progs/a745.py index 1d9fe80..9a21dfa 100644 --- a/progs/a745.py +++ b/progs/a745.py @@ -12,4 +12,4 @@ def find_rotation_count(A):              right = mid - 1
          elif A[mid] >= A[left]:
              left = mid + 1
 -    return -1
 +    return -1
\ No newline at end of file diff --git a/progs/test.py b/progs/test.py new file mode 100644 index 0000000..718885d --- /dev/null +++ b/progs/test.py @@ -0,0 +1,17 @@ +import math +from re import f4, r3 + +from abs import * + + +def find_first_duplicate(nums, x): +    num_set = set() +    no_duplicate = -1 + +    for i in range(len(nums)): +        if nums[i] in num_set: +            return nums[i] +        else: +            num_set.add(nums[i]) + +    return no_duplicate diff --git a/progs/test2.py b/progs/test2.py new file mode 100644 index 0000000..c62d44a --- /dev/null +++ b/progs/test2.py @@ -0,0 +1,3 @@ +x = 1 +if y == 1: +    print("a") | 
