Matrix Spiral Copy
Function Name: spiralCopy
Description
Write a function 'spiralCopy' that takes a 2D array (matrix) as an input and returns a list (or array) of elements in the order they are visited in a spiral traversal, starting from the top-left corner and proceeding inwards in a clockwise direction.
Requirements
- The function must handle matrices of non-equal width and height.
- Values must be appended to the output list in a spiral order: rightwards along the top row, downwards along the far right column, leftwards along the bottom row, and upwards along the far left column, continuously moving inwards in a spiral pattern.
- The function must not use any in-built matrix traversal functions or libraries.
- The function should return an empty list if the input matrix is empty.
- The function should have O(n) time complexity, where n is the number of elements in the matrix.
- The parameters should only include the matrix, without additional arguments to specify bounds.
Examples
Given the following matrix:1 2 34 5 67 8 9spiralCopy([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) should return [1, 2, 3, 6, 9, 8, 7, 4, 5].Given a 1x4 matrix:spiralCopy([[1, 2, 3, 4]]) should return [1, 2, 3, 4].Given an empty matrix:spiralCopy([]) should return [].
Links
Flatten Nested Dictionary
Sat Dec 28 2024
In this challenge, you are to write a function named 'flatten_dictionary' that takes a dictionary with nested dictionaries as values and returns a new dictionary with flattened keys.The keys in the output dictionary should be a combination of the nested keys, separated by a period ('.').If an inner dictionary has an empty key, it should just be appended without the preceding dot.Values from nested dictionaries are to be included in the result as is, without further nesting.The input dictionary will only contain other dictionaries or scalar values (e.g., strings, integers).
Balanced Brackets
Mon Dec 30 2024
In this task, you are required to write a function `isBracketsBalanced` that takes a single string parameter containing various types of brackets such as `(), {}, []`. The function must check whether the input string's brackets are balanced. In the context of this challenge, balanced brackets mean that each opening bracket has a matching closing bracket, and the pairs of brackets are properly nested. Your function must return a boolean result indicating whether the brackets are balanced or not.