Skip to content

Instantly share code, notes, and snippets.

View Shaddyjr's full-sized avatar
📉
You must construct additional models

Mahdi Shadkam-Farrokhi Shaddyjr

📉
You must construct additional models
View GitHub Profile
// source: https://www.hackerrank.com/challenges/palindrome-index/problem
// video: https://youtu.be/IoiYMKmvuPQ
function isPalindrome(s){
let left = 0
let right = s.length - 1
while(left < right){ // O(n)
if(s[left]!==s[right]){
return false
}
left++
# source: https://www.hackerrank.com/challenges/palindrome-index/problem
# video: https://youtu.be/IoiYMKmvuPQ
def is_palindrome(s):
left = 0
right = len(s) - 1
while left < right: # O(n)
if s[left] != s[right]:
return False
left += 1
# source: https://www.hackerrank.com/challenges/xor-quadruples/problem
# video: https://youtu.be/LyOpIRgobsc
def beautifulQuadruples(a, b, c, d):
# sorting values for consistency and order doesn't matter with XOR operation
sorted_input = sorted([a, b, c, d])
A, B, C, D = sorted_input
# Given the maximum number D, the most significant bit sets the limit for
# how much space is needed for C_D_memo
// source: https://www.hackerrank.com/challenges/xor-quadruples/problem
// video: https://youtu.be/LyOpIRgobsc
function beautifulQuadruples(a, b, c, d) {
// sorting values for consistency and order doesn't matter with XOR operation
const sortedInput = [a, b, c, d]
sortedInput.sort((val1, val2) => val1 - val2)
const [A, B, C, D] = sortedInput
// Given the maximum number D, the most significant bit sets the limit for
# Problem: https://www.hackerrank.com/challenges/alphabet-rangoli/problem?
# YouTube: https://youtu.be/ZJsyQTEeiYI
# char a as Unicode code
start = 97 # 'a'
def print_rangoli(size):
lines = []
for i in range(size):
line = create_line(start + i, size - i, size)
lines.append(line)