Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 1.36 KB

leetcode_two_107.md

File metadata and controls

60 lines (41 loc) · 1.36 KB

a

https://leetcode.cn/problems/find-maximum-number-of-string-pairs/

class Solution {
    public int maximumNumberOfStringPairs(String[] words) {
        Set<String> set = new HashSet<>();

        int res = 0;
        for (int i = 0; i < words.length; i ++) {
            String a = words[i];
            if (set.contains(a)) {
                res ++;
                set.remove(a);
            } else {
                set.add(new StringBuilder(a).reverse().toString());
            }
        }
        return res;
    }
}

b

https://leetcode.cn/problems/construct-the-longest-new-string/description/

class Solution {
    public int longestString(int x, int y, int z) {
        return (Math.min(x, y) * 2 + (x != y ? 1 : 0) + z) * 2;
    }
}

c

https://leetcode.cn/problems/decremental-string-concatenation/

d

https://leetcode.cn/problems/count-zero-request-servers/