First q : Write an algorithm to determine if a given string contains a balanced

Do you need this or any other assignment done for you from scratch?
We have qualified writers to help you.
We assure you a quality paper that is 100% free from plagiarism and AI.
You can choose either format of your choice ( Apa, Mla, Havard, Chicago, or any other)

NB: We do not resell your papers. Upon ordering, we do an original paper exclusively for you.

NB: All your data is kept safe from the public.

Click Here To Order Now!

First q :
Write an algorithm to determine if a given string contains a balanced

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!!!

Do you need this or any other assignment done for you from scratch?
We have qualified writers to help you.
We assure you a quality paper that is 100% free from plagiarism and AI.
You can choose either format of your choice ( Apa, Mla, Havard, Chicago, or any other)

NB: We do not resell your papers. Upon ordering, we do an original paper exclusively for you.

NB: All your data is kept safe from the public.

Click Here To Order Now!

Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount