Simple Time Conversion
Function Name: convertTo24HrFormat
Description
Write a function that converts 12-hour time format to 24-hour time format.
The function will take a string representing the time in 12-hour format as input, e.g., '02:15PM' or '11:45AM'.
It should return a string representing the time in 24-hour format, e.g., '14:15' or '11:45'.
The input string will always be a valid time with uppercase 'AM' or 'PM'.
Requirements
- The function must take one parameter - the input time string.
- The function should handle both 'AM' and 'PM' times correctly.
- Midnight is represented as '00:00' in 24-hour format, and noon is '12:00'.
- Do not use any third-party libraries or date/time built-in functions.
- Assume standard input, i.e., no leap seconds, daylight savings adjustments, etc.
Examples
If the input is '01:00PM', the function should return '13:00'.If the input is '12:00AM', the function should return '00:00'.If the input is '07:30AM', the function should return '07:30'.If the input is '12:45PM', the function should return '12:45'.
Subarray Sum Equals K
Tue Aug 27 2024
Write a function subarraySum that takes an array of integers and an integer value k as its parameters.The function should return the number of continuous subarrays whose sum equals to k.A subarray is a contiguous part of the array.
Balanced Parentheses
Thu Aug 29 2024
Write a function that takes a string containing only '(', ')', '{', '}', '[' and ']', determines if the input string is valid. An input string is valid if:1. Open brackets must be closed by the same type of brackets.2. Open brackets must be closed in the correct order.3. An empty string is considered balanced.