Pergunta de entrevista da empresa Paytm

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true Example 2: Input: s = "()[]{}" Output: true Example 3: Input: s = "(]" Output: false Example 4: Input: s = "([])" Output: true Given an array of size N filled with numbers from 1 to N-1 in random order. The array has only one repetitive element. The task is to find the repetitive element. Examples: Input: a[] = {1, 3, 2, 3, 4} Output: 3 Explanation: The number 3 is the only repeating element. Input: a[] = {1, 5, 1, 2, 3, 4} Output: 1 Brute Force To Optimization