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
const aws = require("aws-sdk") | |
const iam = new aws.IAM() | |
const ec2 = new aws.EC2() | |
const securityGroupNames = [ | |
"allow-internal-ingress", | |
"allow-internal-egress", | |
"allow-external-egress" | |
] |
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 solution(A): | |
total = sum(A) | |
diff = sum(range(1, len(A) + 2)) | |
return abs(diff - total) |
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 | |
def solution(X, Y, D): | |
return int(math.ceil(float(Y - X) / float(D))) |
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 solution(A, K): | |
if len(A) == 0: | |
return A | |
for _ in range(K): | |
A.insert(0, A.pop()) | |
return A |
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 solution(A): | |
table = dict() | |
for num in A: | |
if not table.get(num): | |
table[num] = 1 | |
else: | |
table.pop(num) | |
return table.keys()[0] |
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 solution(N): | |
max = 0 | |
bits = 0 | |
bin = "{0:b}".format(N) | |
for c in bin: | |
if c == "0": | |
bits += 1 | |
if c == "1": | |
if max < bits: |
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
long bits = 0; | |
long max = 0; | |
void binary(long N) { | |
if (N > 1) { | |
binary(N / 2); | |
} | |
if (N % 2 == 0) { | |
bits += 1; | |
return; |
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
#include <iostream> | |
#include <array> | |
#include <map> | |
#include <random> | |
using std::cout; | |
using std::endl; | |
using std::string; | |
using std::array; |
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
function solution(N, A) { | |
var M = A.length; // Length of the entry array | |
var C = []; // Counters | |
var H = 0; // Highest counter | |
var PH = 0; // Previously recorded highest counter | |
for(K = 0; K < N; K++) { // Initialize the array | |
C[K] = 0; | |
} | |
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
function solution(A) { | |
var F = []; // Found list | |
var I = 0, V = 0; // Counter, container | |
while (I < A.length) { // Iterate through the array | |
V = A[I]; // Store the value | |
I++; // Increase counter | |
if (F[V]) continue; // If the value exists, continue | |
F[V] = true; // Store the value | |
} |
NewerOlder