Skip to content

Instantly share code, notes, and snippets.

View atul-chaudhary's full-sized avatar
🎯
Focusing

Atul Chaudhary atul-chaudhary

🎯
Focusing
View GitHub Profile
@atul-chaudhary
atul-chaudhary / example.dart
Last active July 31, 2020 12:11
flutter windows issue
error while running
//////////
Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Exception: Build process failed. To view the stack trace, please run `flutter run -d windows -v`.
///////////////
run with flutter stack trace
@atul-chaudhary
atul-chaudhary / program10.py
Created September 29, 2019 03:55
leetocde 876: Find the middle element of linked list
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
fst=head
slw=head
@atul-chaudhary
atul-chaudhary / program9.py
Created September 29, 2019 03:22
leetcode: problem
class Solution:
def getHint(self, secret: str, guess: str) -> str:
d = {}
bull = 0
cow = 0
for i in range(len(secret)):
if (secret[i] == guess[i]):
bull += 1
else:
if (secret[i] in d):
@atul-chaudhary
atul-chaudhary / program8.py
Created September 24, 2019 09:27
leetcode:693
class Solution:
def hasAlternatingBits(self, n: int) -> bool:
st=''
while(n>0):
st+=str(n%2)
n=n//2
for i in range(len(st)-1):
if(st[i]==st[i+1]):
return False
else:
@atul-chaudhary
atul-chaudhary / program7.py
Created September 24, 2019 09:03
program7:- leetcode 205 Isomorphic strings.
#program is not 100% correct faling in some test cases.
# i am working on it and efficiency can also be increased
class Solution:
def isIsomorphic(self, s, t):
d = {}
if(s==t):
return True
else:
for i in range(len(s)):
@atul-chaudhary
atul-chaudhary / program6.py
Created September 14, 2019 02:43
traveloka : programming Question
1
10
A 10
A 15
A 20
I 10
A 22
D 5
A 27
P 3
@atul-chaudhary
atul-chaudhary / program5.py
Created September 10, 2019 08:36
leetcode 101 symmetric tree recursive approach
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
@atul-chaudhary
atul-chaudhary / program4.py
Created September 10, 2019 02:46
leetcode 914: X of a Kind in a Deck of Cards
class Solution:
def hasGroupsSizeX(self, deck) -> bool:
d = {}
for i in range(len(deck)):
if (deck[i] in d):
d[deck[i]] += 1
else:
d[deck[i]] = 1
print(d)
for x in range(2, len(deck) + 1):
@atul-chaudhary
atul-chaudhary / program3.py
Created September 10, 2019 01:48
leetcode program to find out dominant index in a list
class Solution:
def dominantIndex(self, nums) -> int:
m=max(nums)
print(m)
m_index=nums.index(m)
for i in range(len(nums)):
if(nums[i]==0 or nums[i]==m):
pass
elif(m//nums[i]<2):
return -1
@atul-chaudhary
atul-chaudhary / program2.py
Created September 9, 2019 15:41
Program to print all subset of a list in python
lst=[1,2,3,4]
lst1=[]
lst1.append([])
for i in range(len(lst)):
tmp_lst=[]
for j in range(i+1,len(lst)+1):
tmp_lst=lst[i:j]
lst1.append(tmp_lst)
print(lst1)