This is a list of my favorite coding problems from platforms like LeetCode and HackerRank, along with their corresponding solutions.
-
Contains Duplicate
- Problem: Check if an array contains any duplicates.
- Platform: LeetCode
-
Two Sum
- Problem: Find two numbers in an array that add up to a specific target.
- Platform: LeetCode
-
Roman Numbers to Integers
- Problem: Convert Roman numerals to integers.
- Platform: Custom
-
isPalindrome (String)
- Problem: Check if a string is a palindrome.
- Platform: Custom
-
isPalindrome (int)
- Problem: Determine if an integer is a palindrome.
- Platform: Custom
-
Sorted Squared Array
- Problem: Square the elements of a sorted array while keeping them sorted.
- Platform: Custom
-
First Non-Repeating Character
- Problem: Find the first non-repeating character in a string.
- Platform: LeetCode
-
isValid Parenthesis
- Problem: Check if a given string of parentheses is valid.
- Platform: LeetCode
-
Min Add to Make Parenthesis Valid
- Problem: Find the minimum number of parentheses needed to make a string valid.
- Platform: LeetCode
-
Find Peak in Mountain Array
- Problem: Find the peak element in an array that represents a mountain.
- Platform: LeetCode
-
Longest Common Subsequence
- Problem: Find the length of the longest common subsequence between two strings.
- Platform: HackerRank
-
Length of Longest Common Subsequence
- Problem: Find the length of the longest common subsequence in an array of strings.
- Platform: Custom
-
Search Suggestion System
- Problem: Implement a search suggestion system based on user input.
- Platform: LeetCode
-
Common Number in Three Arrays
- Problem: Find a common number that exists in three arrays.
- Platform: Custom
-
Minimum Number of Coins
- Problem: Determine the minimum number of coins needed to make a specific amount.
- Platform: Custom
-
Replace with Right Max
- Problem: Replace each element in an array with the rightmost element greater than the current element.
- Platform: Custom
-
Tic Tac Toe
- Problem: Given a list of moves in a game of tic tac toe, return that state of the game.
- If player A (the first player to move with X characters) wins, return ”A”.
- If player B (the second player to move with O characters) wins, return ”B”.
- Otherwise, if it’s a draw, return ”Draw” and if the game hasn’t finished, return ”Pending”.
- Ex: Given the following moves…
- moves = [[0,0],[1,0],[1,1],[2,0],[2,2]], return "A" (player A won with three Xs being connected along the diagonal).
- Platform: Daily Byte
More to come 👍