Skip to content

Commit 25271be

Browse files
committed
Added 2185 2186
1 parent 27e5f2c commit 25271be

3 files changed

+34
-0
lines changed

Readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@
651651
| 2140 | [Solving Questions With Brainpower](src/2140.solving-questions-with-brainpower.py) | Medium | O(N) | O(N) | Array, Dynamic Programming | | |
652652
| 2176 | [Count Equal and Divisible Pairs in an Array](src/2176.count-equal-and-divisible-pairs-in-an-array.py) | Easy | O(N^2) | O(1) | Array | | |
653653
| 2177 | [Count Equal and Divisible Pairs in an Array](src/2177.find-three-consecutive-integers-that-sum-to-a-given-number.py) | Medium | O(1) | O(1) | Math, Binary Search | | |
654+
| 2185 | [Counting Words With a Given Prefix](src/2185.counting-words-with-a-given-prefix.py) | Easy | O(N) | O(1) | Array, String | | |
655+
| 2186 | [Minimum Number of Steps to Make Two Strings Anagram II](src/2186.minimum-number-of-steps-to-make-two-strings-anagram-ii.py) | Medium | O(N) | O(N) | Hash Table, String, Counting | | |
654656
| 2190 | [Most Frequent Number Following Key In an Array](src/2190.most-frequent-number-following-key-in-an-array.py) | Easy | O(N) | O(N) | Array, Hash Table, Counting | | |
655657
| 2191 | [Sort the Jumbled Numbers](src/2191.sort-the-jumbled-numbers.py) | Medium | O(NlogN) | O(1) | Array, Sorting | | |
656658
| 2192 | [All Ancestors of a Node in a Directed Acyclic Graph](src/2192.all-ancestors-of-a-node-in-a-directed-acyclic-graph.py) | Medium | O(N+V) | O(U+V) | DFS, BFS, Topological Sort, Graph | | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# @lc app=leetcode id=2185 lang=python3
3+
#
4+
# [2185] Counting Words With a Given Prefix
5+
#
6+
7+
# @lc code=start
8+
from typing import List
9+
10+
11+
class Solution:
12+
def prefixCount(self, words: List[str], pref: str) -> int:
13+
return sum(w.startswith(pref) for w in words)
14+
# @lc code=end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# @lc app=leetcode id=2186 lang=python3
3+
#
4+
# [2186] Minimum Number of Steps to Make Two Strings Anagram II
5+
#
6+
7+
# @lc code=start
8+
# TAGS: Hash Table, String, Counting
9+
import collections
10+
11+
12+
class Solution:
13+
def minSteps(self, s: str, t: str) -> int:
14+
c1 = collections.Counter(s)
15+
c2 = collections.Counter(t)
16+
return sum((c1 - c2).values()) + sum((c2 - c1).values())
17+
18+
# @lc code=end

0 commit comments

Comments
 (0)