力扣2744-最大字符串配对数目

最大字符串配对数目

题目链接

解题思路

1.暴力模拟,由题意可知,使得第i个字符串和第j个字符串互为反转字符串即可

c++ 复制代码
class Solution {
public:
    int maximumNumberOfStringPairs(vector<string>& words) {
        int ans=0;
        for(int i = 0; i<words.size();i++){
            for(int j = i + 1; j < words.size();j++){
                if(words[i][0] == words[j][1] && words[i][1] == words[j][0]){
                    ans++;
                    break;
                }
            }
        }
        return ans;
    }
};
相关推荐
米粒12 小时前
力扣算法刷题 Day 27
算法·leetcode·职场和发展
Fuxiao___3 小时前
C 语言核心知识点讲义(循环 + 函数篇)
算法·c#
Mr_Xuhhh3 小时前
LeetCode hot 100(C++版本)(上)
c++·leetcode·哈希算法
漫随流水3 小时前
c++编程:反转字符串(leetcode344)
数据结构·c++·算法
穿条秋裤到处跑5 小时前
每日一道leetcode(2026.03.31):字典序最小的生成字符串
算法·leetcode
CoovallyAIHub7 小时前
VisionClaw:智能眼镜 + Gemini + Agent,看一眼就能帮你搜、帮你发、帮你做
算法·架构·github
CoovallyAIHub7 小时前
低空安全刚需!西工大UAV-DETR反无人机小目标检测,参数减少40%,mAP50:95提升6.6个百分点
算法·架构·github
CoovallyAIHub7 小时前
IEEE Sensors | 湖南大学提出KGP-YOLO:先定位风电叶片再检测缺陷,三数据集mAP均超87%
算法
Yupureki7 小时前
《算法竞赛从入门到国奖》算法基础:动态规划-路径dp
数据结构·c++·算法·动态规划
副露のmagic8 小时前
数组章节 leetcode 思路&实现
算法·leetcode·职场和发展