Odd-Even List Separation
Function Name: separateOddEven
Description
Write a function 'separateOddEven' that takes an array of integers as a parameter. The function should separate the odd and even numbers from the array and return an object with two array properties: 'odd' and 'even'.
The 'odd' array should include all the odd numbers from the input array in the same order they appeared, and the 'even' array should include all the even numbers in the same order they appeared.
The function should not use any built-in sort methods and should iterate over the input array only once.
Requirements
- The function must take a single parameter: an array of integers.
- It should return an object with properties 'odd' and 'even', both of which are arrays that contain the separated odd and even numbers, respectively.
- Iterate over the array only once.
- Do not use any external libraries or built-in sorting methods.
- Maintain the relative order of the odd and even numbers as they appeared in the original array.
- Assume the input array does not contain non-integer values.
Examples
If the function is called with the following array: [4, 1, 3, 2, 6, 5], it should return { odd: [1, 3, 5], even: [4, 2, 6] }.Calling the function with an empty array should return { odd: [], even: [] }.
Clock Angle Calculator
Thu Jul 25 2024
Write a function named `findClockAngle` that calculates the smaller angle between the hour and minute hands on a traditional 12-hour analogue clock. The function should take two integer parameters, representing the hour and the minute, and return the smaller angle in degrees as an integer. If there are two possible angles (which could happen at times like 6:00), the function should return the smaller of the two. The function must handle cases where the hour is greater than 12 or less than 1, or where the minutes are greater than 59 or less than 0 by adjusting them to the correct values that would appear on a clock.
Balanced Brackets
Sat Jul 27 2024
Implement a function to check if a given string containing only '(', ')', '[', ']', '{', and '}' has balanced brackets. The brackets must close in the correct order, '(', ')', '{', '}', and '[', ']', where each opening bracket has a corresponding closing bracket. A bracket sequence is considered balanced if each opening bracket is followed by the corresponding closing bracket and the order of brackets is correct.