Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data_structures/strings/allunique.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def has_unique_chars(s):

Check failure on line 1 in data_structures/strings/allunique.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/allunique.py:1:1: INP001 File `data_structures/strings/allunique.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/allunique.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/allunique.py:1:1: INP001 File `data_structures/strings/allunique.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/allunique.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/allunique.py:1:1: INP001 File `data_structures/strings/allunique.py` is part of an implicit namespace package. Add an `__init__.py`.
seen = set()
for char in s:
if char in seen:
return False
seen.add(char)
return True

# Example
s = "abcdefga"
print("Unique Characters:", has_unique_chars(s))
7 changes: 7 additions & 0 deletions data_structures/strings/anagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from collections import Counter

Check failure on line 1 in data_structures/strings/anagram.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

data_structures/strings/anagram.py:1:1: I001 Import block is un-sorted or un-formatted

Check failure on line 1 in data_structures/strings/anagram.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/anagram.py:1:1: INP001 File `data_structures/strings/anagram.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/anagram.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

data_structures/strings/anagram.py:1:1: I001 Import block is un-sorted or un-formatted

Check failure on line 1 in data_structures/strings/anagram.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/anagram.py:1:1: INP001 File `data_structures/strings/anagram.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/anagram.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

data_structures/strings/anagram.py:1:1: I001 Import block is un-sorted or un-formatted

Check failure on line 1 in data_structures/strings/anagram.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/anagram.py:1:1: INP001 File `data_structures/strings/anagram.py` is part of an implicit namespace package. Add an `__init__.py`.

def are_anagrams(s1, s2):
return Counter(s1) == Counter(s2)

# Example
print("Anagram:", are_anagrams("listen", "silent"))
8 changes: 8 additions & 0 deletions data_structures/strings/frequencyofeachchar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def char_frequency(s):

Check failure on line 1 in data_structures/strings/frequencyofeachchar.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/frequencyofeachchar.py:1:1: INP001 File `data_structures/strings/frequencyofeachchar.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/frequencyofeachchar.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/frequencyofeachchar.py:1:1: INP001 File `data_structures/strings/frequencyofeachchar.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/frequencyofeachchar.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/frequencyofeachchar.py:1:1: INP001 File `data_structures/strings/frequencyofeachchar.py` is part of an implicit namespace package. Add an `__init__.py`.
freq = {}
for char in s:
freq[char] = freq.get(char, 0) + 1
return freq

# Example
print(char_frequency("datastructure"))
10 changes: 10 additions & 0 deletions data_structures/strings/reverseword.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def reverse_words(sentence):

Check failure on line 1 in data_structures/strings/reverseword.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/reverseword.py:1:1: INP001 File `data_structures/strings/reverseword.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/reverseword.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/reverseword.py:1:1: INP001 File `data_structures/strings/reverseword.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in data_structures/strings/reverseword.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

data_structures/strings/reverseword.py:1:1: INP001 File `data_structures/strings/reverseword.py` is part of an implicit namespace package. Add an `__init__.py`.
words = sentence.split()
stack = []
for word in words:
stack.append(word)
reversed_sentence = ' '.join(stack[::-1])
return reversed_sentence

# Example
print(reverse_words("Data Structures in Python"))
Loading