First q :
Write an algorithm to determine if a given string contains a balanced sequence of parentheses.
Input
The input consists of a string containing “(” or “)” only.
Output
Print an Integer representing the count of balanced pairs if the string is balanced. Else print -1 Second q2:
Write an algorithm to find the number of occurrences of needle in a given positive number haystack.
Input
The first line of the input consists of an integer needle, representing a digit.
The second line consists of an integer haystack, representing the positive number.
Output
Print an integer representing the number of occurrences of needle in haystack,
Constraints
0 ≤ needle ≤ 9
0 ≤ haystack ≤ 99999999
Example
Input:
2
123228
Output:
3
Dont use chatgpt at all I can use it!!!
Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount