This file contains 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
SELECT sub.ip FROM | |
(SELECT set_masklen(((generate_series(1, | |
(2 ^ (32 - masklen('10.10.100.0/24'::cidr)))::integer - 2) + | |
'10.10.100.0/24'::cidr)::inet), 32) as ip) AS sub | |
WHERE sub.ip NOT IN | |
(SELECT ip_address from ip_table) | |
AND sub.ip > set_masklen('10.10.100.0/24', 32)+10 | |
AND sub.ip < set_masklen(broadcast('10.10.100.0/24')::inet, 32)-5; |
This file contains 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 math | |
import os | |
import random | |
import re | |
import sys | |
# Complete the triangle function below. |
This file contains 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 delta_encode(array): | |
first = False | |
pre = None | |
diff = None | |
res = [] | |
for i in array: | |
if not first: | |
res.append(i) | |
first = True | |
pre = i |
This file contains 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: 1 case fails | |
import math | |
import os | |
import random | |
import re | |
import sys | |
This file contains 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
# | |
# Sample input for the program | |
# 7 60 | |
# 201305641 2 | |
# The quick brown fox jumps over the lazy dog | |
# the quick brown fox jumps over the lazy dog the | |
# 201305581 2 | |
# The leisurely fox leisurely jumps over leisurely lazy dog | |
# the leisurely fox leisurely jumps over the leisurely lazy dog | |
# 201305051 2 |
This file contains 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
# Given a matrix: | |
# 1,0,0,0,0 | |
# 0,0,1,0,1 | |
# 0,1,1,1,1 | |
# 0,0,0,1,0 | |
# 1,0,0,0,1 | |
# | |
# find the maximum number of shaded cells (represented by 1) that share an edge with each other. | |
# eg. in the case above there are 7 cells that contains 1 and share an edge with each other | |
# |
This file contains 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
//Enter your code here. Read input from STDIN. Print output to STDOUT | |
// | |
//What is the execution order in the following program, and also the output ? | |
package main | |
import "fmt" | |
var WhatIsThe = AnswerToLife() | |
func AnswerToLife() int { | |
fmt.Println("asdfasdfasdf") | |
return 42 |
This file contains 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
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
# DENOMINATIONS: 5 10 20 50 | |
# BILLS: 4 3 1 1 | |
# withdraw(75): return the number of bills/denomination (e.g.: one bill of 5, one bills of 20, one bill of 50) | |
NOTES = { | |
# 1: 10, | |
5: 4, |
This file contains 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
# Complete the 'maxPathSum' function below. | |
# | |
# The function is expected to return an INTEGER. | |
# The function accepts following parameters: | |
# 1. 2D_INTEGER_ARRAY board | |
# 2. INTEGER p | |
# 3. INTEGER q | |
# NOTE use a dict to cache the results ro improve performance. |
This file contains 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
# Complete the countSpecialElements function below. | |
def countSpecialElements(matrix): | |
items = set() | |
for m, row in enumerate(matrix): | |
min_i, max_i, solution = min_max_in_list(row) | |
if not solution: | |
return -1 | |
# add as row_col | |
items.add('%d_%d' % (m, min_i)) | |
items.add('%d_%d' % (m, max_i)) |
NewerOlder