Problem Solving 101 [0]

We’ll be starting a series to improve our problem solving skills:

We’ll discuss the following problems in this stream:

1. Codeforces 306A #

You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).

Input
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.

Output
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.

2. Write a function that takes a list of strings an prints them, one per line, in a rectangular frame. For example the list [“Hello”, “World”, “in”, “a”, “frame”] gets printed as: #

*********
* Hello *
* World *
* in    *
* a     *
* frame *
*********

3. Write a function that merges two sorted lists into a new sorted list. [1,4,6],[2,3,5] → [1,2,3,4,5,6]. You can do this quicker than concatenating them followed by a sort. #

4. Balanced Parentheses (easy) #

Given a string str of length N, consisting of ‘(‘ and ‘)‘ only, the task is to check whether it is balanced or not.
Examples:

Input: str = “((()))()()” 
Output: Balanced

Input: str = “())((())” 
Output: Not Balanced 

5. Given N points in the form (x,y) find if a rectangle can be formed with the given points #