Skip to content

Instantly share code, notes, and snippets.

Some text here
@Daksh
Daksh / use.md
Last active January 6, 2016 05:58
Useful Stuff

#Useful Stuff

##Sugar Packages

  • Install: sugar-install-bundle /run/media/<USB device name>/<filename.xo>
  • Make an xo: zip -r YourActivityName.xo YourActivityName.activity

##GIT

Always remember, do not make changes directly in the master branch. All it takes is a command to make and switch to a new branch git checkout -b

@Daksh
Daksh / first.py
Created August 7, 2020 19:40
Binary Tree Level Order Traversal II
from collections import deque
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def levelOrderBottom(self, root: TreeNode) -> List[List[int]]:
if not root:
@Daksh
Daksh / ArrangingCoins.py
Created August 7, 2020 19:45
Arranging Coins
class Solution:
def arrangeCoins(self, n: int) -> int:
i = 1
while i*(i+1)/2<=n:
i+=1
return i-1
@Daksh
Daksh / PrisonCellsAfterNDays.py
Created August 7, 2020 20:47
Prison Cells After N Days
class Solution:
def prisonAfterNDays(self, cells: List[int], N: int) -> List[int]:
memory = {}
for it in range(N):
ocells = cells[:]
for i in range(1,7):
if ocells[i-1]==ocells[i+1]:
cells[i] = 1
else:
cells[i] = 0
@Daksh
Daksh / FindLongestAwesomeSubstring.py
Created August 8, 2020 16:58
1542. Find Longest Awesome Substring
def isPalindrome(l,r):
diff = {}
for k in l.keys():
diff[k] = r[k]-l[k]
diff = list(diff.values())
countOdd = 0
for e in diff:
if e%2==1:
countOdd+=1
if countOdd<=1: