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
| # https://codefights.com/arcade/code-arcade/labyrinth-of-nested-loops/W5Sq7taLSzNHh8GiF | |
| def crosswordFormation(words): | |
| count = 0 | |
| for i in range(4): | |
| ta = words[i] | |
| al = len(ta) | |
| for a in range(al - 2): | |
| for j in range(4): | |
| if j == i: |
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
| #!/usr/bin/python | |
| #-*- encoding: utf-8 -*- | |
| def spiral_print_matrix(matrix): | |
| height = len(matrix) | |
| if height == 0 or len(matrix[0]) == 0: | |
| return | |
| width = len(matrix[0]) | |
| level = height < width and height or width | |
| for i in range((level + 1) / 2): |
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
| #!/usr/bin/python | |
| #-*- encoding: utf-8 -*- | |
| def spiral_print_matrix(matrix): | |
| height = len(matrix) | |
| if height == 0 or len(matrix[0]) == 0: | |
| return | |
| width = len(matrix[0]) | |
| level = height < width and height or width | |
| for i in range((level + 1) / 2): |
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
| # | |
| # Binary trees are already defined with this interface: | |
| # class Tree(object): | |
| # def __init__(self, x): | |
| # self.value = x | |
| # self.left = None | |
| # self.right = None | |
| def hasPathWithGivenSum(t, s): | |
| if t is None: | |
| if s==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
| # Singly-linked lists are already defined with this interface: | |
| # class ListNode(object): | |
| # def __init__(self, x): | |
| # self.value = x | |
| # self.next = None | |
| # | |
| def removeKFromList(l, k): | |
| if l == None: | |
| return l | |
| while l != None and l.value == k: |
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
| # Singly-linked lists are already defined with this interface: | |
| # class ListNode(object): | |
| # def __init__(self, x): | |
| # self.value = x | |
| # self.next = None | |
| # | |
| def removeKFromList(l, k): | |
| if l == None: | |
| return l | |
| while l != None and l.value == k: |
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
| Note: Try to solve this task in-place (with O(1) additional memory), since this is what you'll be asked to do during an interview. | |
| You are given an n x n 2D matrix that represents an image. Rotate the image by 90 degrees (clockwise). | |
| Example | |
| For | |
| a = [[1, 2, 3], |
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
| (Linkedin = { | |
| release: '1.0.5 stable', | |
| data: {}, | |
| config: { | |
| autoStart: true, | |
| inspectorSpeed: 5000, | |
| sendSpeed: 4000, | |
| pagerSpeed: 10000, | |
| scrollDownAuto: 600, | |
| debug: true, |
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
| import random #bring in the random number | |
| import time | |
| number=random.randint(1, 200) #pick the number between 1 and 200 | |
| def intro(): | |
| print("May I ask you for your name?") | |
| name=input() #asks for the name | |
| print(name + ", we are going to play a game. I am thinking of a number between 1 and 200") | |
| time.sleep(.5) | |
| print("Go ahead. Guess!") |