Balanced Parentheses
Function Name: isBalanced
Description
Write a function that takes a string containing only parentheses '()', '[]', and '{}' characters. The function must check whether the parentheses in the string are correctly balanced. Every opening parenthesis must have a corresponding closing parenthesis of the same type, and parentheses must close in the correct order. Your function should return true if the string is balanced, otherwise, return false.
Requirements
- The function should take a single parameter: a string containing only characters '()', '[]', and '{}'.
- The function should return a boolean indicating whether the string has balanced parentheses.
- An empty string should be considered as balanced.
- The function must handle nested and non-nested parentheses structures.
- Do not use regular expressions to solve this problem; use stacks or other data structure techniques instead.
Examples
Given the string '()[]{}', your function should return true.Given the string '(]', your function should return false.Given the string '([{}])', your function should return true.Given the string '({[)]', your function should return false.Given an empty string '', your function should return true.
Links
Fibonacci Finder
Fri Oct 25 2024
Write a function named `fibonacci_at_index` that takes one integer parameter, `n`,and returns the nth number in the Fibonacci sequence, where the sequence starts with 0 (zero based indexing).The Fibonacci sequence is defined by the following recurrence relation:F(0) = 0, F(1) = 1,F(n) = F(n - 1) + F(n - 2)for n > 1. Your solution should be efficient enough to handle values of `n` up to 30 withoutsignificant performance degradation. Avoid recursion that can lead to a stack overflow, or inefficientcomputations that lead to long processing times.
Prime Factorization
Sun Oct 27 2024
Write a function `calculatePrimeFactors` that receives a single positive integer greater than 1 and returns an array of its prime factors.Prime factors are the prime numbers that multiply together to equal the given integer. Every number greater than 1 is either a prime itself or can be made by multiplying prime numbers together.The returned array should contain the prime factors sorted in ascending order. If the input number is prime, return an array with just that number as the only element.