Here are some of my solutions to a few of my favorite coding challenges!
NOTE: All problems & challenges are pulled off LeetCode. All solutions are original. The LeetCode ID is listed for each problem.
Count Odd Numbers in an Interval Range (#1523)
Given two non-negative integers
lowandhigh. Return the count of odd numbers betweenlowandhigh(inclusive).
Circular Sentence (#2490)
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
- For example,
"Hello World","HELLO","hello world hello world"are all sentences.
Words consist of only uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different.
A sentence is circular if:
- The last character of each word in the sentence is equal to the first character of its next word.
- The last character of the last word is equal to the first character of the first word.
For example,
"leetcode exercises sound delightful","eetcode","leetcode eats soul"are all circular sentences. However,"Leetcode is cool","happy Leetcode","Leetcode"and"I like Leetcode"are not circular sentences.
Given a string
sentence, returntrueif it is circular. Otherwise, returnfalse.
Combinations (#77)
Given two integers
nandk, return all possible combinations ofknumbers chosen from the range[1, n].
You may return the answer in any order.
Sorting the Sentence (#1859)
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.
A sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence.
- For example, the sentence
"This is a sentence"can be shuffled as"sentence4 a3 is2 This1"or"is2 sentence4 This1 a3".
Given a shuffled sentence
scontaining no more than9words, reconstruct and return the original sentence.
Goal Parser Interpretation (#1678)
You own a Goal Parser that can interpret a string
command. Thecommandconsists of an alphabet of"G","()"and/or"(al)"in some order. The Goal Parser will interpret"G"as the string"G","()"as the string"o", and"(al)"as the string"al". The interpreted strings are then concatenated in the original order.Given the string
command, return the Goal Parser‘s interpretation ofcommand.
Defanging an IP Address (#1108)
Given a valid (IPv4) IP
address, return a defanged version of that IP address.
A defanged IP address replaces every period
"."with"[.]".



