Skip to content

Instantly share code, notes, and snippets.

View harrysharma1's full-sized avatar
🖥️
Learning

Harry Sharma harrysharma1

🖥️
Learning
View GitHub Profile
<nav class="flex w-full flex-col border-b-1 border-gray-700 bg-gray-950 pt-5 pl-5 text-white">
<div class="flex flex-row">
<div class="flex items-center gap-4">
<svg height="32" aria-hidden="true" viewBox="0 0 24 24" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github v-align-middle" fill="white">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-
@harrysharma1
harrysharma1 / contains_duplicate.py
Created June 22, 2023 14:10
My solution for contains duplicate
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
s=set(nums)
return len(nums)-len(s)>0
@harrysharma1
harrysharma1 / 3_sum.py
Created June 7, 2023 19:53
My solution for 3 sum leet code
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
if len(nums)<3:
return []
if len(nums)==3:
if sum(nums)==0:
return [nums]
else:
return []
nums.sort()
@harrysharma1
harrysharma1 / single_number.py
Created June 3, 2023 18:35
My solution to leetcode single number problem
class Solution:
def singleNumber(self, nums: List[int]) -> int:
m={}
for i in nums:
if i not in m.keys():
m[i]=0
m[i]+=1
for i,j in m.items():
if j==1:
return i
@harrysharma1
harrysharma1 / roman_to_integer.py
Created May 30, 2023 16:20
My solution to LeetCode Roman to Integer problem
Class Solution:
def romanToInt(self, s: str) -> int:
roman = {'M': 1000,'D': 500 ,'C': 100,'L': 50,'X': 10,'V': 5,'I': 1}
sum= 0
for i in range(0, len(s) - 1):
if roman[s[i]] < roman[s[i+1]]:
sum -= roman[s[i]]
else:
sum+= roman[s[i]]
return sum + roman[s[-1]]
@harrysharma1
harrysharma1 / palindrome_number.py
Created May 30, 2023 16:19
My solution to Leetcode palindrome number
class Solution:
def isPalindrome(self, x: int) -> bool:
s=str(x)
for x in range(len(s)//2):
if s[x]!=s[-x-1]:
return False
return True