Last active
December 18, 2020 16:27
-
-
Save derigible/74ead9bdb759cdaeff39acb0ba8ee801 to your computer and use it in GitHub Desktop.
Coding Challenges
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
# Given numbers n and k, divide n by k and return the quotient and remainder | |
# without using the divider (/) operator. | |
# Example: | |
# Input: 5, 2 | |
# Output: [2, 1] | |
# Input: 4, 2 | |
# Output: [2, 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
# Given a string, check if that string can become a palindrome if | |
# a single character is removed from that string. Return true if so, false otherwise. | |
# Example: | |
# Input: 'tacocats' | |
# Output: true | |
# Input: 'tacoscats' | |
# Output: false | |
# Input: 'tacocat' | |
# Output: false |
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
# You are given a set of students represented by a tuple of (relative_height, # of students taller than student ahead in line) | |
# In other words, the first value of the tuple represents the relative height | |
# of the student in the class with 1 being the shortest, and the second value | |
# is the number of other students ahead of the given student that are taller | |
# than them. Each student only knows how many students are taller. | |
# Given this set, reconstruct the original line order and return the order in an array with | |
# the first element being the front of the line. | |
# Example: | |
# Input: Set({(4,1), (3,0), (5,0), (2,3), (1,3)}) | |
# Output: Will only provide a hint - try to reconstruct manually as it will largely dictate the algorithm |
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
# Given a text (such as a book, user input, etc.), find the top n | |
# words of the text. | |
# | |
# Example: | |
# | |
# Input: "The quick brown fox ran quick to the brown thickets over by the brook.", n = 3 | |
# Output: ["the", "quick", "brown"] | |
# | |
# Note that words which are a tie can come in any order and if there are more words | |
# that are a tie than what is asked for then any of those words are valid outputs. | |
# Definition of a word is a string of characters surrounded by spaces. Punctuation | |
# at the end of the word does not make a new word. | |
# For example, "end" and "end." are the same word; "end-time" and "end-time" are the same | |
# word; "endzone" and "endzone.\n" are the same. Note that '' is not considered a word. | |
# "end\nzone" will be two words - "end" and "zone" | |
# "end1" is considered a word. "@gmail.com" is considered one word. | |
# capitalization does not matter - "one" and "One" are the same word. | |
# if n is greater than the number of unique words, return all words - ie "the and only", n = 4 will | |
# return ["the", "and", "only"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment