Question
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
Constraints:
1 <= s.length <= 104sconsists of parentheses only'()[]{}'.
Python Solution
class Solution:
def isValid(self, s: str) -> bool:
stack=[]
boo = True
for ch in s:
if ch in '([{':
stack.append(ch)
elif ch in ')]}':
try:
popped_element = stack.pop()
except:
boo=False
break
if popped_element=='(' and ch==')':
pass
elif popped_element=='{' and ch=='}':
pass
elif popped_element=='[' and ch==']':
pass
else:
boo=False
break
if len(stack)==0:
return (boo)
else:
return (False)

![[Solved] You are given an integer n and an integer start. Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length. Return the bitwise XOR of all elements of nums.](https://machinelearningprojects.net/wp-content/uploads/2022/09/Leetcode-solutions-MLP-Feature-Image-1024x536.webp)