This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def arrangeCoins(self, n: int) -> int: | |
i = 1 | |
while i*(i+1)/2<=n: | |
i+=1 | |
return i-1 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
#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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some text here |