diff --git a/solution/3900-3999/3940.Limit Occurrences in Sorted Array/README_EN.md b/solution/3900-3999/3940.Limit Occurrences in Sorted Array/README_EN.md
new file mode 100644
index 0000000000000..13846d9b9864a
--- /dev/null
+++ b/solution/3900-3999/3940.Limit Occurrences in Sorted Array/README_EN.md
@@ -0,0 +1,128 @@
+---
+comments: true
+difficulty: Easy
+edit_url: https://github.com/doocs/leetcode/edit/main/solution/3900-3999/3940.Limit%20Occurrences%20in%20Sorted%20Array/README_EN.md
+---
+
+
+
+# [3940. Limit Occurrences in Sorted Array](https://leetcode.com/problems/limit-occurrences-in-sorted-array)
+
+## Description
+
+
+
+
You are given a sorted integer array nums and an integer k.
+
+Return an array such that each distinct element appears at most k times, while preserving the relative order of the elements in nums.
+
+Note: If a distinct element appears at least k times, then it must appear exactly k times in the resulting array.
+
+
+
+Example 1:
+
+
+
+
Input: nums = [1,1,1,2,2,3], k = 2
+
+
Output: [1,1,2,2,3]
+
+
Explanation:
+
+
+- The element
1 appears 3 times, so only 2 occurrences are kept.
+- The element
2 appears 2 times, so both occurrences are kept.
+- The element
3 appears 1 time, so it is kept.
+
+
+
Thus, the resulting array is [1,1,2,2,3].
+
+
+
+Example 2:
+
+
+
+
Input: nums = [1,2,3], k = 1
+
+
Output: [1,2,3]
+
+
Explanation:
+
+
All elements are distinct and already appear at most once, so the array remains unchanged.
+
+
+
+
+
+Constraints:
+
+
+1 <= nums.length <= 100
+1 <= nums[i] <= 100
+nums is sorted in non-decreasing order.
+1 <= k <= nums.length
+
+
+
+
+## Solutions
+
+
+
+### Solution 1: Counting Consecutive Elements
+
+Since the array is sorted, duplicate elements appear consecutively.
+
+We maintain a counter to track occurrences of the current element.
+
+If the occurrence count is less than or equal to k, we add the element to the result list.
+
+The time complexity is O(n), where n is the length of the array.
+
+The space complexity is O(n).
+
+
+
+#### Java
+
+```java
+class Solution {
+ public int[] limitOccurrences(int[] nums, int k) {
+
+ List list = new ArrayList<>();
+
+ int count = 1;
+
+ list.add(nums[0]);
+
+ for (int i = 1; i < nums.length; i++) {
+
+ if (nums[i] == nums[i - 1]) {
+ count++;
+ } else {
+ count = 1;
+ }
+
+ if (count <= k) {
+ list.add(nums[i]);
+ }
+ }
+
+ int[] ans = new int[list.size()];
+
+ for (int i = 0; i < list.size(); i++) {
+ ans[i] = list.get(i);
+ }
+
+ return ans;
+ }
+}
+```
+
+
+
+
+
+
diff --git a/solution/3900-3999/3940.Limit Occurrences in Sorted Array/Solution.java b/solution/3900-3999/3940.Limit Occurrences in Sorted Array/Solution.java
new file mode 100644
index 0000000000000..122229bcbbd03
--- /dev/null
+++ b/solution/3900-3999/3940.Limit Occurrences in Sorted Array/Solution.java
@@ -0,0 +1,22 @@
+class Solution {
+ public int[] limitOccurrences(int[] nums, int k) {
+ List list = new ArrayList<>();
+ int count = 1;
+ list.add(nums[0]);
+ for (int i = 1; i < nums.length; i++) {
+ if (nums[i] == nums[i - 1]) {
+ count++;
+ } else {
+ count = 1;
+ }
+ if (count <= k) {
+ list.add(nums[i]);
+ }
+ }
+ int[] ans = new int[list.size()];
+ for (int i = 0; i < list.size(); i++) {
+ ans[i] = list.get(i);
+ }
+ return ans;
+ }
+}
diff --git a/solution/3900-3999/3941.Password Strength/README_EN.md b/solution/3900-3999/3941.Password Strength/README_EN.md
new file mode 100644
index 0000000000000..59f4a85971584
--- /dev/null
+++ b/solution/3900-3999/3941.Password Strength/README_EN.md
@@ -0,0 +1,129 @@
+---
+comments: true
+difficulty: Medium
+edit_url: https://github.com/doocs/leetcode/edit/main/solution/3900-3999/3941.Password%20Strength/README_EN.md
+---
+
+
+
+# [3941. Password Strength](https://leetcode.com/problems/password-strength)
+
+## Description
+
+
+
+You are given a string password.
+
+The strength of the password is calculated based on the following rules:
+
+
+- 1 point for each distinct lowercase letter (
'a' to 'z').
+- 2 points for each distinct uppercase letter (
'A' to 'Z').
+- 3 points for each distinct digit (
'0' to '9').
+- 5 points for each distinct special character from the set
"!@#$".
+
+
+Each character contributes at most once, even if it appears multiple times.
+
+Return an integer denoting the strength of the password.
+
+
+
+Example 1:
+
+
+
+
Input: password = "aA1!"
+
+
Output: 11
+
+
Explanation:
+
+
The distinct characters are 'a', 'A', '1' and '!'.
+
+
Thus, the strength = 1 + 2 + 3 + 5 = 11.
+
+
+
+Example 2:
+
+
+
+
Input: password = "bbB11#"
+
+
Output: 11
+
+
Explanation:
+
+
The distinct characters are 'b', 'B', '1' and '#'.
+
+
Thus, the strength = 1 + 2 + 3 + 5 = 11.
+
+
+
+
+
+Constraints:
+
+
+1 <= password.length <= 105
+password consists of lowercase and uppercase English letters, digits, and special characters from "!@#$".
+
+
+
+
+## Solutions
+
+
+
+### Solution 1: HashSet
+
+We use a HashSet to store distinct characters.
+
+For each distinct character:
+- Add 1 if it is lowercase.
+- Add 2 if it is uppercase.
+- Add 3 if it is a digit.
+- Add 5 if it is one of !@#$.
+
+The time complexity is O(n), where n is the length of the string.
+
+The space complexity is O(1).
+
+
+
+#### Java
+
+```java
+class Solution {
+ public int passwordStrength(String password) {
+ Set set = new HashSet<>();
+
+ for (char ch : password.toCharArray()) {
+ set.add(ch);
+ }
+
+ int ans = 0;
+
+ for (char ch : set) {
+ if (Character.isLowerCase(ch)) {
+ ans += 1;
+ } else if (Character.isUpperCase(ch)) {
+ ans += 2;
+ } else if (Character.isDigit(ch)) {
+ ans += 3;
+ } else {
+ ans += 5;
+ }
+ }
+
+ return ans;
+ }
+}
+```
+
+
+
+
+
+
diff --git a/solution/3900-3999/3941.Password Strength/Solution.java b/solution/3900-3999/3941.Password Strength/Solution.java
new file mode 100644
index 0000000000000..655a8c62d51ea
--- /dev/null
+++ b/solution/3900-3999/3941.Password Strength/Solution.java
@@ -0,0 +1,18 @@
+class Solution {
+ public int passwordStrength(String password) {
+ Set set = new HashSet<>();
+ int count = 0;
+ for(int i=0;i= 'a' && c <= 'z') count += 1;
+ else if(c >= 'A' && c <= 'Z') count += 2;
+ else if(c >= '0' && c <= '9') count+=3;
+ else if(c == '!' || c == '@' || c == '#' || c == '$') count+=5;
+ }
+ return count;
+ }
+}