Skip to content

Commit fe26a41

Browse files
author
Carlos Gutierrez
committed
Add missing problem 2116 to README table and fix row numbering
1 parent d614bbc commit fe26a41

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ This repo tracks my journey solving LeetCode problems — not just code, but my
103103
| 72 | 1302 | [Deepest Leaves Sum](src/exercises/1302.deepest-leaves-sum.py) | Medium | Python |
104104
| 73 | 2016 | [Maximum Difference Between Increasing Elements](src/exercises/2016.maximum-difference-between-increasing-elements.py) | Easy | Python |
105105
| 74 | 2053 | [Kth Distinct String in an Array](src/exercises/2053.kth-distinct-string-in-an-array.py) | Easy | Python |
106-
| 75 | 2294 | [Partition Array Such That Maximum Difference Is K](src/exercises/2294.partition-array-such-that-maximum-difference-is-k.py) | Medium | Python |
107-
| 76 | 3442 | [Maximum Difference Between Even and Odd Frequency I](src/exercises/3442.maximum-difference-between-even-and-odd-frequency-i.py) | Easy | Python |
108-
| 77 | 3582 | [Generate Tag for Video Caption](src/exercises/3582.generate-tag-for-video-caption.py) | Easy | Python |
109-
| 78 | 3583 | [Count Special Triplets](src/exercises/3583.count-special-triplets.py) | Easy | Python |
106+
| 75 | 2116 | [Check if a Parentheses String Can Be Valid](src/exercises/2116.check-if-a-parentheses-string-can-be-valid.py) | Medium | Python |
107+
| 76 | 2294 | [Partition Array Such That Maximum Difference Is K](src/exercises/2294.partition-array-such-that-maximum-difference-is-k.py) | Medium | Python |
108+
| 77 | 3442 | [Maximum Difference Between Even and Odd Frequency I](src/exercises/3442.maximum-difference-between-even-and-odd-frequency-i.py) | Easy | Python |
109+
| 78 | 3582 | [Generate Tag for Video Caption](src/exercises/3582.generate-tag-for-video-caption.py) | Easy | Python |
110+
| 79 | 3583 | [Count Special Triplets](src/exercises/3583.count-special-triplets.py) | Easy | Python |
110111

111112
## 🛠️ Tools & Scripts
112113
- `create_missing_notes.sh`: Automatically creates missing note files for solved problems
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from string import *
2+
from re import *
3+
from datetime import *
4+
from collections import *
5+
from heapq import *
6+
from bisect import *
7+
from copy import *
8+
from math import *
9+
from random import *
10+
from statistics import *
11+
from itertools import *
12+
from functools import *
13+
from operator import *
14+
from io import *
15+
from sys import *
16+
from json import *
17+
from builtins import *
18+
import string
19+
import re
20+
import datetime
21+
import collections
22+
import heapq
23+
import bisect
24+
import copy
25+
import math
26+
import random
27+
import statistics
28+
import itertools
29+
import functools
30+
import operator
31+
import io
32+
import sys
33+
import json
34+
from typing import *
35+
36+
37+
# @leet start
38+
class Solution:
39+
def canBeValid(self, s: str, locked: str) -> bool:
40+
if len(s) % 2 != 0:
41+
return False
42+
mo = 0
43+
mxo = 0
44+
for i in range(len(s)):
45+
if locked[i] == "1":
46+
mo = mo + 1 if s[i] == "(" else mo - 1
47+
mxo = mxo + 1 if s[i] == "(" else mxo - 1
48+
else:
49+
mo -= 1
50+
mxo += 1
51+
if mxo < 0:
52+
return False
53+
mo = mo if mo > 0 else 0
54+
return mo == 0
55+
56+
57+
# @leet end

0 commit comments

Comments
 (0)