Coding
Case style
Variable
var counter = 0; var processCounter = 0;var elementCounter = 0; var processCounter = 0;
var prev = 0; var cur = 0;var prev = 0; var curr = 0;key = "hello" value = "world" call(key, value)call("hello", "value")
for (var i=0; i <length; i++) { }var i = "hello".indexOf("l");var idx = "hello".indexOf("l");var books = getBooks()var bookList = getBookList()
def count_triplets(arr, r): count = 0 dict = {} dictPairs = {} for i in reversed(arr): if i*r in dictPairs: count += dictPairs[i*r] if i*r in dict: dictPairs[i] = dictPairs.get(i, 0) + dict[i*r] dict[i] = dict.get(i, 0) + 1 return countdef count_triplets_3(arr, r): count = 0 dict = {} dictPairs = {} for i in reversed(arr): prod = i*r if prod in dictPairs: count += dictPairs[prod] if prod in dict: dictPairs[i] = dictPairs.get(i, 0) + dict[prod] dict[i] = dict.get(i, 0) + 1 return countd:\dvp\python\hackerrank>python src\count_triplets.py count_triplets : 0:00:02.621734 count_triplets_3: 0:00:02.252786 d:\dvp\python\hackerrank>python src\count_triplets.py count_triplets : 0:00:02.626448 count_triplets_3: 0:00:02.250635 d:\dvp\python\hackerrank>python src\count_triplets.py count_triplets : 0:00:02.632636 count_triplets_3: 0:00:02.246863
Block
Comment
Brain Melting Coding
Best practice
Last updated