Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a40ba0c

Browse files
committed
Added the leetcode link.
1 parent 7b186b5 commit a40ba0c

File tree

2 files changed

+58
-11
lines changed

2 files changed

+58
-11
lines changed

.idea/workspace.xml

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Link: https://leetcode.com/problems/find-maximum-number-of-string-pairs/
3+
4+
Find Maximum Number of String Pairs
5+
You are given a 0-indexed array words consisting of distinct strings.
6+
7+
The string words[i] can be paired with the string words[j] if:
8+
9+
The string words[i] is equal to the reversed string of words[j].
10+
0 <= i < j < words.length.
11+
Return the maximum number of pairs that can be formed from the array words.
12+
13+
Note that each string can belong in at most one pair.
14+
15+
Example 1:
16+
Input: words = ["cd","ac","dc","ca","zz"]
17+
Output: 2
18+
Explanation: In this example, we can form 2 pair of strings in the following way:
19+
- We pair the 0th string with the 2nd string, as the reversed string of word[0] is "dc" and is equal to words[2].
20+
- We pair the 1st string with the 3rd string, as the reversed string of word[1] is "ca" and is equal to words[3].
21+
It can be proven that 2 is the maximum number of pairs that can be formed.
22+
23+
Example 2:
24+
Input: words = ["ab","ba","cc"]
25+
Output: 1
26+
Explanation: In this example, we can form 1 pair of strings in the following way:
27+
- We pair the 0th string with the 1st string, as the reversed string of words[1] is "ab" and is equal to words[0].
28+
It can be proven that 1 is the maximum number of pairs that can be formed.
29+
30+
Example 3:
31+
Input: words = ["aa","ab"]
32+
Output: 0
33+
Explanation: In this example, we are unable to form any pair of strings.
34+
35+
Constraints:
36+
1 <= words.length <= 50
37+
words[i].length == 2
38+
words consists of distinct strings.
39+
words[i] contains only lowercase English letters.
40+
*/
41+
package com.raj;
42+
43+
public class FindMaximumNumberOfStringPairs {
44+
45+
}

0 commit comments

Comments
 (0)