Balanced Brackets
Function Name: isBalanced
Description
Write a function `isBalanced` that takes a string containing only brackets `()[]{}` and checks if the string is balanced. A string is balanced if all brackets are correctly closed and nested. The function should return `true` if the input string is balanced, otherwise, it should return `false`.
Requirements
- The function must handle an empty string, and consider it as balanced.
- The function must not use any external libraries or packages.
- The function should have a time complexity of O(n), where n is the length of the string.
- You may use any standard data structures provided by the language's standard library.
- Carefully consider edge cases where brackets are nested improperly.
- The input string will contain only brackets and no other characters.
Examples
`isBalanced('[](){}')` should return `true`.`isBalanced('[(]{})')` should return `false`.`isBalanced('')` should return `true`.`isBalanced('([{}])')` should return `true`.`isBalanced('([{]})')` should return `false`.
Links
Subarray Sum Equals K
Sun Dec 15 2024
Write a function named 'subarraySum' that takes in an array of integers and an integer 'k', and returns the number of continuous subarrays whose sum equals to 'k'.
Path Finder in a Grid
Tue Dec 17 2024
Write a function named pathFinder that finds a path from the top-left corner to the bottom-right corner of a 2D grid. The grid is represented as a matrix of 0s and 1s, where 0 indicates a walkable cell, and 1 indicates an obstacle. The function needs to return a boolean indicating whether a path exists. You should move horizontally or vertically, but not diagonally.