Пример #1
0
def main():
	# root = practice.Node(1)
	# left1 = practice.Node(1)
	# left2 = practice.Node(1)
	# root.left = left1
	# left1.right = left2
	# print isBalanced(root)
	root = practice.convertSortedArrayToBST([0,1,2,3,4,5,6,7,8,9,10])
	# lists = createLevelList_main(root)
	# for i in lists:
	# 	result = []
	# 	for node in i:
	# 		result.append(node.data)
	# 	print result
	# findSum_main(root, 7)
	# inorderTraversal(root)
	# preorderTraversal(root)
	levelorderTraversal(root)
Пример #2
0
def main():
	# print findIntersectionOfTwoLists([1,2,3,4,5],[1,3,5,9,10])
	# print validParentheses("()[()()({}{}[{}{}]{})()]{}}}")
	# print validPalidrome("race a car")
	# print fourSum([1,2,3,4,5,6], 13)
	# print pow_imp(3,3)
	# print wordLadder1("hit", "cog", ["hot","dot","dog","lot","log"])
	# print mergeIntervals([(1,3), (2,4), (5,7), (6,8)])
	# print removeElement([1,2,3,4,3,3], 3)
	# print insertInterval([[1,3],[6,9]], [2,5])
	# l1 = practice.LLNode(1)
	# l2 = practice.LLNode(2)
	# l3 = practice.LLNode(3)
	# l4 = practice.LLNode(4)
	# l1.next = l2
	# l2.next = l3
	# l3.next = l4
	# head = swapNodesInPair(l1)
	# displayLL(head)
	# print combinations(10, 2)
	# root = practice.convertSortedArrayToBST([1,2,3,4,5])
	# print sumRootToLeafNumbers(root)
	"""
	1  4  7  11 15
	2  5  8  12 19
	3  6  9  16 22
	10 13 14 17 24
	18 21 23 26 30
	"""
	# print search2DMatrix([[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], 30)
	# print cropMatrix([[1,2,3],[1,2,3],[1,2,3]], 1,2,1,2)
	# print findMedianOfAnArray([2,1,4,3, 8, 7,5,6])
	# print addBinary("11", "1")
	# testTrie()
	# print longestCommonSubstring("ABAB", "BABA")
	# print reverseArrayOfWordsInPlace([1,2,3,4])
	# columns = [0] * GRID_SIZE
	# results = []
	# placeQueens(0, columns, results)
	# print results
	# print uniquePaths(3,7)
	# print uniquePath_dp(3, 7)
	root = practice.convertSortedArrayToBST([1,2,3,4,5,6,7,8,9,10])
	# print inorderSuccessor(root.left.left).data
	# print decodeWays("12101123432")
	# print maximumSubArray([-2,1,-3,4,-1,2,1,-5,4])
	# minimumPathSum([[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], 5, 5)
	# print bestTimeToBuyAndShareStock([2,3,4,1,3,7])
	# print root.right.data
	# displayFlattenTree(flattenTree(root))
	# print minimumTriangle([10, 30, 20, 101, 102, 103, 10000, 10001, 10002])
	# print romanToInteger("MMX|||")
	# print exp(4,3)
	# print palindromPartition("aab")
	# print regularExpressionMatching("aa", "a")
	# print regularExpressionMatching("aa", "aa")
	# print regularExpressionMatching("aaa", "aa")
	# print regularExpressionMatching("aa", "a*")
	# print regularExpressionMatching("aa", ".")
	# print regularExpressionMatching("ab", ".*")
	# print regularExpressionMatching("aab", "c*a*b")
	# populateNextRightPointer2(root)
	# print divideTwoIntegers(100, 5)
	# ls = [6,7,8,9,10,11,1,2,3,4,5]
	# print searchInRSA(ls, 2)
	# for i in ls:
		# print searchInRSA(ls, i)
	print searchForRange([1,4,4,4,5,6,7], 4)
	# print threeSum([-25, -10, -7, -3, 2, 4, 8, 10], -25)
	# print generateParentheses(4)
	# print strStr("", "asdf")
	# array = [1,2,3,3,4,5]
	# print removeDuplicatesFromSortedArray(array)
	# print sqrt(3)
	# print pathSum(root, 12)
	# print reverseInteger(123)
	# printBSTLevelByLevel2(root)
	# array = [1,2,3,4,5,6,7,8,9]
	# randomizeNumbers(array)
	# print array
	# expression = "65+34+-"
	# print reversePolishNotation(expression)
	print reverseWordsInAText("I want to get a job")