sudo !!
ctrl + x + e
def howManyAgentsToAdd(noOfCurrentAgents, callsTimes): | |
_min = sys.maxint | |
_max = -sys.maxint | |
start = 0 | |
end = 1 | |
for c in callsTimes: | |
if _min > c[start]: | |
_min = c[start] | |
#!/usr/bin/python | |
def removeObstacleUtil(numRows, numColumns, lot, row, col): | |
if not row and not col: | |
return 1 + min(removeObstacleUtil(numRows, numColumns, lot, row + 1, col), | |
removeObstacleUtil(numRows, numColumns, lot, row, col + 1)) | |
elif row == numRows - 1 and col == numColumns - 1: | |
return -1 | |
elif row == numRows - 1: | |
return 1 + removeObstacleUtil(numRows, numColumns, lot, row, col + 1) |
int min(int A, int B) { | |
return A < B ? A : B; | |
} | |
int removeObstacleUtil(int numRows, int numColumns, int **lot, int row, int col) { | |
if (!row && !col) | |
return 1 + min(removeObstacleUtil(numRows, numColumns, lot, row + 1, col), | |
removeObstacleUtil(numRows, numColumns, lot, row, col + 1)); | |
else if (row == numRows - 1 && col == numColumns - 1) | |
return -1; |
def find_string(): | |
N = int(raw_input()) | |
words = {} | |
for i in range(0, N): | |
w = raw_input() | |
if w in words: | |
words[w] += 1 | |
else: | |
words[w] = 1 |
import collections | |
def club_logs_by_uuid(logs): | |
logs_by_uuid = collections.defaultdict(list) | |
for log in logs: | |
logs_by_uuid[log.split(' ')[2]].append(log) | |
return logs_by_uuid | |
def main(): |
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
BACKTRACE_START_STR = 'Traceback ' | |
BACKTRACE_END_STR = 'raise ' | |
BACKTRACE_SEPARATOR = '-' * 50 | |
def search_and_print_backtrace(logs): | |
line = 0 | |
is_backtrace = False | |
is_first_backtrace = True |
# Complete the countSubSequence function below. | |
def countSubSequence(inputSeq, targetSum): | |
size = len(inputSeq) | |
count = 0 | |
for i in range(0, size): | |
for j in range(i + 1, size + 1): | |
subSeq = inputSeq[i:j] | |
if sum(subSeq) == targetSum: | |
count += 1 | |
return count |
def requiredAmountAtStart(netSaving): | |
initial_money = 0 | |
net = 0 | |
for e in netSaving: | |
net += e | |
if net <= 0: | |
initial_money += 1 + (-1 * net) | |
net += 1 + (-1 * net) | |
return initial_money |
#!/usr/bin/env python | |
# The following code is buggy. Find and fix the bugs here to make it pass the test cases. | |
# Re-writing the complete code (or core logic) will *not* be accepted. | |
import sys, os | |
def get_layer(array, row, col, width, height): | |
ans = [] |