Balanced Brackets
Function Name: isBalancedBrackets
Description
Write a function that takes a string containing bracket characters ('(', ')', '{', '}', '[' and ']') and checks whether the string contains a balanced set of brackets.
A string has balanced brackets if each type of bracket is properly closed and nested within the string.
The function should return a boolean indicating whether the input string is balanced.
Requirements
- The function must be implemented using a stack data structure.
- It should only consider the bracket characters and ignore other characters in the string.
- The function name must be 'isBalancedBrackets' and take a single parameter (the input string).
- The input string can be empty, in which case the function should return true.
- The function should be able to handle large input strings efficiently.
Examples
isBalancedBrackets('()[]{}') should return true.isBalancedBrackets('(]') should return false.isBalancedBrackets('([)]') should return false.isBalancedBrackets('{[]}') should return true.isBalancedBrackets('a*b+(c-[d/e])') should return true as non-bracket characters are ignored.isBalancedBrackets('') (empty string) should return true.
Links
Validate Subsequence
Sun Dec 01 2024
Write a function that takes in two non-empty arrays of integers. The function should determine whether the second array is a subsequence of the first one.A subsequence of an array is a set of numbers that aren't necessarily adjacent in the array but are in the same order as they appear in the array. For instance, [1, 3, 4] forms a subsequence of [1, 2, 3, 4], and so does [2, 4]. A single number in an array and the array itself are both valid subsequences of the array.You may assume that there will be no duplicate numbers in each array.
String Transformation
Tue Dec 03 2024
Write a function named stringTransform that takes two strings as parameters, source and target. The function should determine if it is possible to transform the source string into the target string by replacing one character at a time. At each step, the new string must be in a given dictionary of valid words. The transformation is case sensitive and must use the smallest number of steps possible. The function should return the number of steps required for the transformation. If the transformation is impossible, the function should return -1.