https://github.com/gustavohenriqueschmitz/coding-challenges
A set of logical coding challenges i faced.
https://github.com/gustavohenriqueschmitz/coding-challenges
Last synced: 4 months ago
JSON representation
A set of logical coding challenges i faced.
- Host: GitHub
- URL: https://github.com/gustavohenriqueschmitz/coding-challenges
- Owner: GustavoHenriqueSchmitz
- Created: 2024-09-22T18:10:48.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-10-25T14:08:23.000Z (9 months ago)
- Last Synced: 2024-10-25T17:41:16.866Z (9 months ago)
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Coding Challenges
## About the repository
Basically it contains some logical coding challenges i've faced. Creating this to share a little of my logical and problem solving abilities as a software developer.## Used Technologies
- Python## About each challenge
### Add two numbers
In this problem, you're given two non-negative integers represented as linked lists. Each node of the linked list contains a single digit, and the digits are stored in reverse order. The goal is to add the two numbers and return the sum as a new linked list, with digits in reverse order as well.- The function simulates the addition of two numbers by traversing the linked lists simultaneously, handling carry-over just like manual addition.
- As a constraint, neither of the numbers has leading zeros, except the number "0" itself.
- Example:
Input: [2, 4, 3] + [5, 6, 4]
Output: [7, 0, 8] (since 342 + 465 = 807)### Baseball Game
You are tasked with calculating the total score of a baseball game. The game has multiple rounds, and in each round, certain operations can modify the score based on the previous rounds.
- Each round can be one of the following operations:
- An integer representing the score of the current round.
- "+" which adds the last two scores.
- "D" which doubles the last score.
- "C" which removes the previous score.
- The challenge is to apply these operations in order and return the sum of the scores after all operations are complete.
- Example:
Input: ["5", "-2", "4", "C", "D", "+"]
Output: 27
Explanation: This simulates the described operations to achieve the final score### Brackets Validator
This challenge involves validating a string composed of different types of brackets ((), [], {}). The goal is to determine if the brackets are correctly balanced, meaning every opening bracket has a corresponding closing bracket in the correct order.
- The string is valid if every opening bracket is matched with the correct closing bracket.
- For example, the string "([{}])" is valid, but "([)]" is not.### String Reverter
The goal of this challenge is to reverse only the alphabetic characters in a string, while keeping the position of any non-letter characters (such as punctuation or spaces) unchanged.
- The function iterates through the string, identifies alphabetic characters, and then reverses only those characters, leaving non-letters in their original positions.
- Example:
Input: "a-bC-dEf=ghlj!!"
Output: "j-lh-gfE=dCb!!"
- Here, only the letters are reversed while keeping the punctuation and equal signs in place### Longest Palindrome String
The goal of this challenge is to find the longest palindromic substring within a given string. A palindrome is a string that reads the same forward and backward. If no palindrome longer than 2 characters exists, the function should return "none".- The function iterates through the string, expanding around each character (or pair of characters) to identify palindromes. It keeps track of the longest palindrome found during the process.
- Example:
Input: "hellosannasmith"
Output: "sannas"
- The substring "sannas" is the longest palindrome in the input string.
- Example:
Input: "abcdefg"
Output: "none"
- Here, no palindrome longer than 2 characters exists, so the function returns "none".## Author
**Gustavo Henrique Schmitz****Linkedin:** https://www.linkedin.com/in/gustavo-henrique-schmitz
**Portfolio:** https://gustavohenriqueschmitz.com
**Email:** [email protected]