Skip to content

Instantly share code, notes, and snippets.

View saarques's full-sized avatar
🛌
Sleeping is a default case to my switch statement.

Sarques saarques

🛌
Sleeping is a default case to my switch statement.
View GitHub Profile
@saarques
saarques / findAnagrams.py
Created January 29, 2025 03:39
Find Anagrams
set1, set2 = ["cbaebabacd", "fish", "abab", "sdsfs", ""], ["abc", "cake", "ab", "", "a"]
for s1, s2 in zip(set1, set2): # Running loop over all test cases
mp1 = {ord('a')+i:0 for i in range(26)} # Creating a dict for all 26 chars
res = [] # Result set
for i in range(len(s2)):
mp1[ord(s2[i])] += 1 # Incrementing the frequency of each character in string 2
for i in range(0, len(s1)-len(s2)+1): # Outer loop for all window of length s2 over s1
@saarques
saarques / sq(s)_in_rect.py
Created July 16, 2018 16:57
Solution of a weekly problem.
n=int(input())
m=int(input())
if m>n:
n,m=m,n
i=1
while m!=0:
print("Number of Square(s) of type ",i,"x",i," : ",n*m)
n,m,i=n-1,m-1,i+1