word-search

题目链接:牛客网
题目描述:
给出一个二维字符数组和一个单词,判断单词是否在数组中出现,
单词由相邻单元格的字母连接而成,相邻单元指的是上下左右相邻。同一单元格的字母不能多次使用。
例如:
给出的字符数组=
[↵ [“ABCE”],↵ [“SFCS”],↵ [“ADEE”]↵]
单词 =“ABCCED”, -> 返回 true,
单词 =“SEE”, ->返回 true,
单词 =“ABCB”, -> 返回 false.

解题思路:来自牛客网 nbgao
把每个点当成string的第一个点遍历,在递归函数中递归这个点的上下左右不超出board的位置找下一个匹配,直到找到所有word的匹配,返回true,否则返回false。

class Solution {
public:
    bool exist(vector<vector<char> > &board, string word) {
        int m = board.size();
        int n = board[0].size();
        for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
                if(DST(board,i,j,0,word))
                    return true;
        return false;
    }
    bool DST(vector<vector<char> > &board,int i,int j,int s,string word)
    {
        int m = board.size();
        int n = board[0].size();
        //符合word的这一位就继续往后找,不符合则直接返回false
        if(word[s] == board[i][j])
        {
        //s == word.size()-1说明匹配完整个word.size
            if(s == word.size()-1)
                return true;
            char c = board[i][j];
            board[i][j] = '*';
            //继续遍历上下左右寻找匹配的字符
            bool flag = (i+1<m && DST(board,i+1,j,s+1,word)) ||
                        (i>0 && DST(board,i-1,j,s+1,word)) ||
                        (j+1<n && DST(board,i,j+1,s+1,word)) ||
                        (j>0 && DST(board,i,j-1,s+1,word));
            board[i][j] = c;
            return flag;
        }
        return false;
    }
};
根据你提供的引用内容,问题是关于Vue组件命名规则的错误。根据\[1\]中的代码,可以看出错误信息是"Component name 'Search' should always be multi-word",意思是组件名"Search"应该是多个单词。根据\[1\]中的配置,可以通过在.eslintrc.js文件中关闭命名规则来解决这个问题。具体的解决方法可以参考\[2\]和\[3\]中的代码示例,其中包括了两种解决方法。第一种是按照规范填写文件名,第二种是在vue.config.js文件中添加代码来关闭语法检查。你可以根据具体情况选择其中一种方法来解决这个问题。 #### 引用[.reference_title] - *1* [报错:error Component name “index“ should always be multi-word vue/multi-word-component-names](https://blog.csdn.net/weixin_57167969/article/details/127750763)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [报错:error Component name “xxx“ should always be multi-word vue/multi-word-component-names](https://blog.csdn.net/m0_70619994/article/details/127931589)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [ error Component name “xxx“ should always be multi-word vue/multi-word-component-names](https://blog.csdn.net/weixin_46713508/article/details/127693222)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值