This file contains hidden or 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
| // 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++ |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| // 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 |
This file contains hidden or 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
| # 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) |
OlderNewer