Skip to content

Instantly share code, notes, and snippets.

View BharathKumarS's full-sized avatar
:octocat:
Committed to constant learning

Bharath Kumar Shivakumar BharathKumarS

:octocat:
Committed to constant learning
View GitHub Profile
@BharathKumarS
BharathKumarS / README
Last active July 26, 2020 21:57
Your GitHub profile README.md file
![Image description here](https://raw.githubusercontent.com/BharathKumarS/BharathKumarS/master/Bharath-Img_Intro.gif "Welcome to my GitHub")
## I'm an Aspiring Data Scientist with a strong analytical background, and 4+ years of experience using Data Engineering, Data Analytics, Data Science, and Agile Software Development skills, I build data-driven solutions. #The_Bharatha <br>
## I enjoy writing technical tutorial blog articles, Participating in Coding contests, Solving Python, and SQL challenges on LeetCode and HackerRank. <br>
> ## Python, SQL, Hadoop, Scala, GitHub, and AWS but not limited to are a few of my preferred tech stack to learn, explore, practice Machine Learning. <br> <br>
<table class='tg'>
<thead>
<tr>
@BharathKumarS
BharathKumarS / RunLen.py
Created April 30, 2020 03:47
Amazon SIP, Run length encoding - Brute force approach with Python.
# Function that gets a string as an parameter
def stringComprress(givenStr):
# Initializing an empty string, it hold the compressed string output from the loop
encoded = ''
# Assuming there is at least one character in the given string
charCount = 1
# Looping through all the characters in the given string
# String with index 1 through the length of the given string
for char in range(1, len(givenStr)):
# Condition to check if the current string is same as previous string
@BharathKumarS
BharathKumarS / Del_Outer_Parentheses.py
Created March 25, 2020 03:51
LeetCode, Remove outermost parentheses
class Solution:
def removeOuterParentheses(self, S):
result = ''
openB = closeB = start = 0
for bracket in range(len(S)):
if S[bracket] == '(':
openB += 1
else:
closeB += 1
if openB == closeB:
@BharathKumarS
BharathKumarS / ReverseStr.py
Created March 20, 2020 14:34
LeetCode, Reverse the given array. Modifying the input array in-place with O(1)
class Solution:
def reverseString(self, s: List[str]) -> None:
s.reverse()
@BharathKumarS
BharathKumarS / StudentReward.py
Created March 18, 2020 18:54
LeetCode, Student Attendance Record I
s = 'PAAALLPALLLLLL'
reward = True
if s.count('A') > 1 or 'LLL' in s:
reward = False
print(reward)
@BharathKumarS
BharathKumarS / Replace-Right.py
Created March 18, 2020 17:13
LeetCode, Replace Elements with Greatest Element on Right Side.
arr = [17,18,5,4,6,1]
for num in range(len(arr)-1):
arr[num] = max(arr[num+1:])
arr[len(arr)-1] = -1
print(arr)
@BharathKumarS
BharathKumarS / Library fine.py
Created March 12, 2020 00:15
HackerRank, Library Fine. A 12 line solution!
def libraryFine(d1, m1, y1, d2, m2, y2):
if y1 > y2:
return(10000)
elif y1 == y2 and m1 > m2:
return(500 * (m1-m2))
elif y1 == y2 and m1 == m2 and d1 > d2:
return(15 *abs(d1-d2))
elif y1 <= y2 and m1 <= m2 and d1 <= d2:
return(0)
elif y1 == y2 and m1 < m2 and d1 > d2:
@BharathKumarS
BharathKumarS / Append and Delete.py
Created March 11, 2020 01:44
HackerRank, Append and Delete. Passed all the test cases.
def appendAndDelete(s, t, k):
given = list(s)
sLen = len(given)
target = list(t)
tLen = len(target)
ops = 0
if sLen > tLen:
while sLen != 0:
try:
if given[sLen-1] == target[sLen-1]:
@BharathKumarS
BharathKumarS / Picking Numbers.py
Created March 9, 2020 00:01
HackerRank, Find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less than or equal to 1
def pickingNumbers(a):
b = list()
tempSum = pairSum = 0
a.sort(reverse=True)
c = sorted(set(a),reverse=True)
for sortNum in c:
b.append([a.count(sortNum), sortNum])
b.sort(key= lambda x:x[1], reverse=True)
for left in b:
for right in b:
@BharathKumarS
BharathKumarS / Climbing the Leaderboard.py
Created March 8, 2020 23:06
HackerRanck, Climbing the Leaderboard challenge. 7/11 test cases passed. I welcome you to modify my code. Thank you for the help.
class Score_board:
def board(self, scores, alice):
self.boardScores = sorted(set(scores), reverse=True)
alice_rank = list(map(self.rankBoard,alice))
return alice_rank
def rankBoard(self, current):
score_bank = self.boardScores
midIndex = len(score_bank)//2
while midIndex > 0: