{}curly brackets or braces[]square brackets or brackets()round brackets or parentheses<>angle brackets or chevrons;semicolon:colon.dot or point,comma""quotation marks\backslash
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
| function findUniq(arr) { | |
| const normalize = (str) => | |
| [...new Set(str.toLowerCase().replace("/s+/g", ""))].sort().join(); | |
| const map = arr.map(normalize).reduce((a, c) => { | |
| a[c] = (a[c] || 0) + 1; | |
| return a; | |
| }, {}); | |
| const uniqueChar = Object.keys(map).find((k) => map[k] === 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
| package kata | |
| import "strings" | |
| func FindShortWord(s string) int { | |
| words := strings.Split(s, " ") | |
| lastWord := words[0] | |
| for i := range words { | |
| currentWord := words[i] |
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
| function sumExcelColumns(cols, column){ | |
| const result = Object.entries(cols) // output: [["A", 0], ["B", 1], ...] | |
| if(!column || column.length <= 0) { | |
| return new Error("Insufficient arguments. Check out to empty string or add a valid argument.") | |
| } | |
| if(column.length === 1) { | |
| for(let i = 0; i < result.length; i++) { | |
| if(result[i][0] === column) { |
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
| [1, 2] === [1, 2] | |
| false | |
| [1, 2, 3] == [1, 2, 3] | |
| false | |
| typeof [1, 2, 3] | |
| "object" | |
| typeof [1, 2, 3] == [1, 2, 3] | |
| false | |
| typeof ([1, 2, 3] == [1, 2, 3]) | |
| "boolean" |
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
| function isPalindrome(str){ | |
| if(str.length <= 1) return true | |
| let end = str.length - 1 | |
| str = str.toLowerCase() | |
| for(let start = 0; start < end; start++) { | |
| if(str[start] !== str[end]) | |
| return false | |
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
| package main | |
| import "fmt" | |
| func main() { | |
| nums := [7]int{2, 3, 5, 3, 7, 11, 13} | |
| m := map[int]bool{} | |
| for i := 0; i < len(primes); i++ { | |
| m[primes[i]] = true |
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
| function alphabetPosition(text) { | |
| let result = [] | |
| for(let i = 0; i < text.length; i++) { | |
| let code = text.toLowerCase().charCodeAt(i) | |
| if(code > 96 && code < 123) result.push(code - 96) | |
| } | |
| return result.join(" ") | |
| } |
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
| .model small | |
| .data | |
| count1 db 2 | |
| .code | |
| main proc | |
| move dl, count1 | |
| add dl, 48 | |
| mov ah, 2h ;code for print char | |
| int 21h ;prints value of "dl" | |
| endp |
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
| // https://en.wikipedia.org/wiki/Wagner–Fischer_algorithm | |
| function editDistance(str1, str2) { | |
| const distance = [] | |
| for(let i = 0; i <= str1.length + 1; i++) { | |
| distance[i] = [i] | |
| } | |
| for(let i = 0; i <= str2.length + 1; i++) { |