Skip to content
Open
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/bongo.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions beginner-level/Problem-1/Problem-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inpt = "bongodev"

out_a= [x for x in inpt]
out_a.reverse()
print("".join(out_a))
8 changes: 8 additions & 0 deletions beginner-level/Problem-1/Problem-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-1: Reverse a String Without Slicing
You are building a simple text utility tool for your web app. One of the requirements is to reverse a string input by a user.

Input: "bongodev"

Output: "vedognob"

Hint: Use a loop to read the string from end to start.
18 changes: 18 additions & 0 deletions beginner-level/Problem-10/Problem-10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def Prime(n):
if n < 0:
return 2
if n == 5 or n == 7 or n == 3 or n == 2 or n == 1:
return 0
if n%2==0 or n%3==0 or n%5==0 or n%7==0:
return 1
else:
return 0
prime_list = []
num = int(input("Enter a number: "))
for i in range(2,(num**2)):
if Prime(i)==0:
print("prime",i)
prime_list.append(i)
else:
print("not prime")
print(prime_list)
8 changes: 8 additions & 0 deletions beginner-level/Problem-10/Problem-10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-10: Check if a Number is Prime
Write a function to check if a number is prime, useful in some encryption schemes.

Input: 29

Output: True

Hint: Check divisibility from 2 to sqrt(n).
10 changes: 10 additions & 0 deletions beginner-level/Problem-2/Problem-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Input= "Data Science is awesome"
vowels= ['a', 'e', 'i', 'o', 'u']
count = 0
for x in Input.lower():
for y in vowels:
if x == y:
count+=1
else:
pass
print(count)
8 changes: 8 additions & 0 deletions beginner-level/Problem-2/Problem-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-2: Count Vowels in a Sentence
As part of a data-cleaning pipeline, count how many vowels are in a string to later analyze readability.

Input: "Data Science is awesome"

Output: 9

Hint: Convert string to lowercase and check each character.
5 changes: 5 additions & 0 deletions beginner-level/Problem-3/Problem-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Input= ["ai", "ml", "python", "ml", "dl", "ai"]
Input_b= set(Input)
for i in Input_b:
if Input.count(i) > 1:
print(i)
8 changes: 8 additions & 0 deletions beginner-level/Problem-3/Problem-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-3: Find Duplicates in a List
You’re given a user-uploaded list of tags. Identify duplicates for suggestion cleanup.

Input: ["ai", "ml", "python", "ml", "dl", "ai"]

Output: ["ml", "ai"]

Hint: Use a dictionary or set to track seen elements.
8 changes: 8 additions & 0 deletions beginner-level/Problem-4/Problem-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Input= "Madam"
Sample_a = list(Input.lower())
Sample_b = Sample_a
Sample_b.reverse()
if Sample_b == Sample_a:
print(True)
else:
print(False)
8 changes: 8 additions & 0 deletions beginner-level/Problem-4/Problem-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-4: Check if a Word is a Palindrome
Write a function that checks if a word or phrase is the same when reversed, ignoring spaces and punctuation.

Input: "Madam"

Output: True

Hint: Normalize the string and compare it to its reverse.
12 changes: 12 additions & 0 deletions beginner-level/Problem-5/Problem-5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Input = [1, [2, 3], [4, [5]]]
B = []
def flatten_list(A):
for item in A:
if isinstance(item, list):
B.extend(flatten_list(item))
else:
B.append(item)
return B


print(flatten_list(Input))
8 changes: 8 additions & 0 deletions beginner-level/Problem-5/Problem-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-5: Flatten a Nested List
You are given a nested list of elements (e.g., UI config data). Flatten it into a single-level list.

- **Input**: `[1, [2, 3], [4, [5]]]`

- **Output**: `[1, 2, 3, 4, 5]`

- **Hint**: Use recursion to handle sublists.
6 changes: 6 additions & 0 deletions beginner-level/Problem-6/Problem-6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Input= "python for web developers"
sample = Input.split(" ")
Output = []
for x in sample:
Output.append(x.capitalize())
print(" ".join(Output))
8 changes: 8 additions & 0 deletions beginner-level/Problem-6/Problem-6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-6: Capitalize First Letter of Each Word
Build a custom title formatter that capitalizes the first letter of each word without using .title().

Input: "python for web developers"

Output: "Python For Web Developers"

Hint: Use .split() and loop through each word.
3 changes: 3 additions & 0 deletions beginner-level/Problem-7/Problem-7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nums = [1,2,3,4,6,7,8,9]
n=len(nums)+1
print(((n*(n+1))//2)-sum(nums))
8 changes: 8 additions & 0 deletions beginner-level/Problem-7/Problem-7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-7: Find Missing Number in a Sequence
You received log files indexed from 1 to n. One log is missing. Find it.

Input: [1, 2, 4, 5]

Output: 3

Hint: Use arithmetic formula for sum of n numbers.
7 changes: 7 additions & 0 deletions beginner-level/Problem-8/Problem-8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def factorial(n):
if n==0:
return 1
else:
return n*factorial(n-1)
A=5
print(factorial(A))
8 changes: 8 additions & 0 deletions beginner-level/Problem-8/Problem-8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-8: Factorial Using Recursion
Write a function to return the factorial of a number, used in data science combinations calculation.

Input: 5

Output: 120

Hint: Base case is 0! = 1, then recurse.
2 changes: 2 additions & 0 deletions beginner-level/Problem-9/Problem-9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A = 9875
print(sum(map(int, list(str(A)))))
8 changes: 8 additions & 0 deletions beginner-level/Problem-9/Problem-9.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem-9: Sum of Digits of an Integer
For a gamification feature, sum the digits of a user’s ID to generate a unique color code.

Input: 9875

Output: 29

Hint: Use // and % or string conversion.
5 changes: 5 additions & 0 deletions intermediate-level/Problem-1/Problem-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def longest_word(sentence):
words = sentence.split()
return max(words, key=len)
A= "Machine learning is fascinating"
print(longest_word(A))
5 changes: 5 additions & 0 deletions intermediate-level/Problem-1/Problem-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Problem-1: Longest Word in a Sentence
Build a function that extracts the longest word from user-generated content.
Input: "Machine learning is fascinating"
Output: "fascinating"
Hint: Split string and use max() with key=len.
12 changes: 12 additions & 0 deletions intermediate-level/Problem-10/Problem-10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import re
from collections import Cou

def most_frequent_word(text, stopwords):
words = re.findall(r'\w+', text.lower())
filtered = [w for w in words if w not in stopwords]
counter = Counter(filtered)
return counter.most_common(1)[0]

stopwords = {"the", "is", "and", "in", "to", "of"}
text = "Machine learning is the future and machine learning is powerful"
print(most_frequent_word(text, stopwords))
3 changes: 3 additions & 0 deletions intermediate-level/Problem-10/Problem-10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Problem-10: Most Frequent Word (Excluding Stopwords)
Analyze blog content and find the most frequent word, excluding common stopwords.
Hint: Clean punctuations, lowercase all, use Counter.
9 changes: 9 additions & 0 deletions intermediate-level/Problem-2/Problem-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from collections import defaultdict

def group_anagrams(words):
anagrams = defaultdict(list)
for word in words:
anagrams[''.join(sorted(word))].append(word)
return list(anagrams.values())
A=["bat", "tab", "cat", "act"]
print(group_anagrams(A))
4 changes: 4 additions & 0 deletions intermediate-level/Problem-2/Problem-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Problem-2: Group Anagrams Together
Group similar words together in a UI (e.g., tags: ["bat", "tab", "cat", "act"]).
Output: [["bat", "tab"], ["cat", "act"]]
Hint: Use a dictionary where sorted word is key.
28 changes: 28 additions & 0 deletions intermediate-level/Problem-3/Problem-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from collections import OrderedDict


class LRUCache:
def __init__(self, capacity: int):
self.cache = OrderedDict()
self.capacity = capacity

def get(self, key: int) -> int:
if key not in self.cache:
return -1
self.cache.move_to_end(key)
return self.cache[key]

def put(self, key: int, value: int):
if key in self.cache:
self.cache.move_to_end(key)
self.cache[key] = value
if len(self.cache) > self.capacity:
self.cache.popitem(last=False)


cache = LRUCache(2)
cache.put(1, 1)
cache.put(2, 2)
print(cache.get(1))
cache.put(3, 3)
print(cache.get(2))
3 changes: 3 additions & 0 deletions intermediate-level/Problem-3/Problem-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Problem-3: Implement an LRU Cache (Least Recently Used)
Simulate caching in a backend system. You need to implement a cache with get() and put() methods.
Hint: Use OrderedDict or create a custom class with a doubly linked list.
8 changes: 8 additions & 0 deletions intermediate-level/Problem-4/Problem-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import re

def validate_email(email):
pattern = r'^[\w\.-]+@[\w\.-]+\.\w+$'
return bool(re.match(pattern, email))

print(validate_email("[email protected]"))
print(validate_email("invalid-email"))
5 changes: 5 additions & 0 deletions intermediate-level/Problem-4/Problem-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Problem-4: Validate Email Format
Write a function that validates emails during user registration.
Input: "[email protected]"
Output: True
Hint: Use regular expressions.
9 changes: 9 additions & 0 deletions intermediate-level/Problem-5/Problem-5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from functools import lru_cache

@lru_cache(maxsize=None)
def fib(n):
if n <= 1:
return n
return fib(n-1) + fib(n-2)

print(fib(50))
5 changes: 5 additions & 0 deletions intermediate-level/Problem-5/Problem-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Problem-5: Fibonacci Using Memoization
Optimize a recursive Fibonacci function using caching, useful in DP-based ML solutions.
Input: 50
Output: 12586269025
Hint: Use @lru_cache from functools.
11 changes: 11 additions & 0 deletions intermediate-level/Problem-6/Problem-6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def flatten_json(data, parent_key='', sep='.'):
items = {}
for k, v in data.items():
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, dict):
items.update(flatten_json(v, new_key, sep=sep))
else:
items[new_key] = v
return items

print(flatten_json({"a": {"b": 1}}))
5 changes: 5 additions & 0 deletions intermediate-level/Problem-6/Problem-6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Problem-6: Flatten a Nested JSON
Flatten a nested dictionary for storage in tabular format or NoSQL DB.
Input: {"a": {"b": 1}}
Output: {"a.b": 1}
Hint: Use recursion.
Loading