LintCode-132: Word Search II (DFS深搜经典难题!)

SAP录入总账凭证报错 公司代码未被分配给国家或用于计算程序的国家消息号 FF703 SAP系统报错FF703的解决方案:当公司代码未分配国家或未配置计税程序时,会导致增值税计算失败。处理方法:1)通过OX02检查公司代码国家字段;2)使用OBBG为国家分配计税程序(如TAXCN)。配置步骤:1)SPRO分配公司代码到国家;2)OBBG设置国家对应的计税程序。注意事项:历史数据需清理才能修改国家字段,不同账簿可配置不同计税程序。完成配置后即可正常处理含税凭证。 阅读详情
  1. Word Search II
    中文English
    Given a matrix of lower alphabets and a dictionary. Find all words in the dictionary that can be found in the matrix. A word can start from any position in the matrix and go left/right/up/down to the adjacent position. One character only be used once in one word. No same word in dictionary

Example
Example 1:

Input:[“doaf”,“agai”,“dcan”],[“dog”,“dad”,“dgdg”,“can”,“again”]
Output:[“again”,“can”,“dad”,“dog”]
Explanation:
d o a f
a g a i
d c a n
search in Matrix,so return [“again”,“can”,“dad”,“dog”].
Example 2:

Input:[“a”],[“b”]
Output:[]
Explanation:
a
search in Matrix,return [].
Challenge
Using trie to implement your algorithm.

解法1:
这题挺难的。我参考的网上的答案。
思路就是暴力深搜 - 每个格子来一次DFS深搜。
注意:

  1. visited[]数组还是需要
  2. 注意剪枝:如果不是prefix,剪掉! 如果出界或已经访问过,剪掉!
  3. char -> string 不能直接用std里面的to_string(),因为char本来就是integer,to_string(char)会生成"100","103"这样的字符串。可以用string(1,c)来生成一个临时的内容为c,长度为1的字符串。
  4. 对于二维数组或vector,用if (board.size() < 1) 比if (board.empty()) 更好
  5. getPrefixSets()里面,下面一行
    if (prefixSets.find(prefix) == prefixSets.end())
    很关键!因为有可能某个word刚好是之前某个prefix,这样可以避免该word被关联到false!
class Solution {
public:
    /**
     * @param board: A list of lists of character
     * @param words: A list of string
     * @return: A list of string
     */
    vector<int> dx = {0, 1, -1, 0};
    vector<int> dy = {1, 0, 0, -1};
    map<string, bool> prefixSets; //放所有的prefix,如果是word就对应true,否则对应false
    
    vector<string> wordSearchII(vector<vector<char>> &board, vector<string> &words) {
        vector<string> result;
        
        if (board.size() < 1)  //比if (board.empty()) 更好?
            return result;
        
        vector<vector<bool>> visited;
        for (int i = 0; i < board.size(); ++i) 
            visited.push_back(vector<bool>(board[i].size(), false));

        getPrefixSets(words);

        set<string> wordSet;
        
        for (int i = 0; i < board.size(); ++i) {
            for (int j = 0; j < board[i].size(); ++j) {
                visited[i][j] = true;
                //char->string 不可以用to_string,否则就是 100->"100"
                helper(board, visited, i, j, string(1, board[i][j]), wordSet); //注意string(1,c)
                visited[i][j] = false;
            }
        }
        
        for (auto w : wordSet)
            result.push_back(w);

        return result;
    }
    
private:
    //generate the map
    void getPrefixSets(vector<string> &words) {
        for (auto w : words) {
            for (int i = 0; i < w.size() - 1; ++i) {  //不需要到w.size(),因为整个word下面会处理
                string prefix = w.substr(0, i + 1); //前i + 1个字符
                if (prefixSets.find(prefix) == prefixSets.end()) //关键!有可能某个word刚好是之前某个prefix,这样可以避免该word被关联到false!
                    prefixSets[prefix] = false;
            }
            prefixSets[w] = true;
        }
    }
    
    void helper(vector<vector<char>> &board, vector<vector<bool>> &visited, int x, int y, string word, set<string> &wordSet) {
        if (prefixSets.find(word) == prefixSets.end())  //如果不是prefix, 剪枝
            return;
        
        if (prefixSets[word]) 
            wordSet.insert(word);
    
        for (int i = 0; i < 4; ++i) {
            int adjX = x + dx[i];
            int adjY = y + dy[i];
            
            if (!inside(board, adjX, adjY) || visited[adjX][adjY])  // 出界或已访问,剪枝
                continue;
            
            visited[adjX][adjY] = true;
            helper(board, visited, adjX, adjY, word + board[adjX][adjY], wordSet);
            visited[adjX][adjY] = false;
        }
    }
    
    bool inside(vector<vector<char>> &board, int x, int y) {
        return x >= 0 &&
               x < board.size() &&
               y >= 0 &&
               y < board[0].size();
    }        
};

二刷:

class Solution {
public:
    /**
     * @param board: A list of lists of character
     * @param words: A list of string
     * @return: A list of string
     *          we will sort your return value in output
     */
    vector<string> wordSearchII(vector<vector<char>> &board, vector<string> &words) {
        unordered_set<string> wordSets;
        unordered_set<string> preSets;
        for (auto word : words) {
            string pre = "";
            for (int i = 0; i < word.size(); i++) {
                pre = pre + word[i];
                preSets.insert(pre);
            }
            wordSets.insert(pre);
        }
        unordered_set<string> sols;
        for (int i = 0; i < board.size(); i++) {
            for (int j = 0; j < board[0].size(); j++) {
                vector<vector<bool>> visited(board.size(), vector<bool>(board[0].size(), false));
                string sol(1, board[i][j]);
                visited[i][j] = true;
                helper(board, wordSets, preSets, i, j, visited, sol, sols);
                visited[i][j] = false;
                sol.pop_back();
            }
        }
        vector<string> res(sols.begin(), sols.end());
        return res;
    }
private:
    void helper(vector<vector<char>> &board, unordered_set<string> &wordSets, unordered_set<string> &preSets,
                int currX, int currY, vector<vector<bool>> &visited, 
                string sol, unordered_set<string> &sols) {
        if (preSets.find(sol) == preSets.end()) return;                
        if (wordSets.find(sol) != wordSets.end() && sols.find(sol) == sols.end()) {
            sols.insert(sol);
        //    return;  //do not stop! continue to search
        }
        for (int i = 0; i < 4; i++) {
            int newX = currX + dx[i];
            int newY = currY + dy[i];
            if (newX < 0 || newX >= board.size() ||
                newY < 0 || newY >= board[0].size() ||
                visited[newX][newY]) continue;
            //sol = sol + board[newX][newY];
            if (preSets.find(sol) != preSets.end()) {
                visited[newX][newY] = true;
                helper(board, wordSets, preSets, newX, newY, visited, sol + board[newX][newY], sols);
                visited[newX][newY] = false;
                //sol.pop_back();  //important
            } //else {
            //    sol.pop_back();
            //}
        }
        return;
    }
    int dx[4] = {0, 0, -1, 1};
    int dy[4] = {-1, 1, 0, 0};
};

解法2:trie+dfs

struct Node {
    Node *ch[26];
    string str;
    Node() {
        for (int i = 0; i < 26; i++) {
            ch[i] = nullptr;
        }
        str = "";
    }
};

class Solution {
public:
    /**
     * @param board: A list of lists of character
     * @param words: A list of string
     * @return: A list of string
     *          we will sort your return value in output
     */
    vector<string> wordSearchII(vector<vector<char>> &board, vector<string> &words) {
        Node *trieRoot = new Node();
        
        for (auto word : words) {
            insert(trieRoot, word);
        }

        unordered_set<string> sols;
        for (int i = 0; i < board.size(); i++) {
            for (int j = 0; j < board[0].size(); j++) {
                vector<vector<bool>> visited(board.size(), vector<bool>(board[0].size(), false));
                
                if (trieRoot->ch[board[i][j] - 'a'] != nullptr) {
                    visited[i][j] = true;
                    search(board, trieRoot->ch[board[i][j] - 'a'], i, j, visited, sols);
                    visited[i][j] = false;
                }
            }
        }
        vector<string> res(sols.begin(), sols.end());
        return res;
    }
private:
    void insert(Node *p, string s) {
        int len = s.size();
        for (int i = 0; i < len; i++) {
            if (p->ch[s[i] - 'a'] == nullptr) {
                p->ch[s[i] - 'a'] = new Node();
            }
            p = p->ch[s[i] - 'a'];
        }
        p->str = s; //store the string at the last node
       // cout << " insert " << p->str << endl;
    }

    void search(vector<vector<char>> &board, Node *node, int x, int y, vector<vector<bool>> &visited, unordered_set<string> &sols) {
        if (!node->str.empty()) {
            sols.insert(node->str);
            //p->str = "";    //can also clear p->str here so there would be no duplicate 
                              //(i.e., we do not need to use set or unordered_set, vector<string> sols is OK)
        }
        for (int i = 0; i < 4; i++) {
            int newX = x + dx[i];
            int newY = y + dy[i];
            if (newX < 0 || newX >= board.size() || newY < 0 || newY >= board[0].size() || visited[newX][newY]) continue;
            if (node->ch[board[newX][newY] - 'a'] != nullptr) {
                visited[newX][newY] = true;
                search(board, node->ch[board[newX][newY] - 'a'], newX, newY, visited, sols);
                visited[newX][newY] = false;
            }
        }
    }

    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
};

注意:

  1. 排重。否则下面的输入例子会有两个"dad"。
    Explanation:
    d o a f
    a g a i
    d c a n
    排重可用set或unordered_set,然后再将结果传给一个vector返回。也可以在得到一个node->str后,将node->str设为"",这样下一次就不会再得到这个node->str。

二刷:

struct TrieNode {
    bool isWord;
    TrieNode * children[26];
    TrieNode() : isWord(false) {
        for (int i = 0; i < 26; i++) {
            children[i] = NULL;
        }
    }
};

class Solution {
public:
    /**
     * @param board: A list of lists of character
     * @param words: A list of string
     * @return: A list of string
     *          we will sort your return value in output
     */
    vector<string> wordSearchII(vector<vector<char>> &board, vector<string> &words) {
        int nRow = board.size();
        int nCol = board[0].size();
        root = new TrieNode();
        visited.resize(nRow, vector<bool>(nCol, false));
        for (auto word : words) insertWord(word);
        unordered_set<string> res;
        for (int i = 0; i < nRow; i++) {
            for (int j = 0; j < nCol; j++) {
                string str = string(1, board[i][j]);
                if (startWith(str)) {
                    visited[i][j] = true;
                    string str = string(1, board[i][j]);
                    helper(board, words, i, j, str, res, visited);
                    visited[i][j] = false;
                }
            }
        }
        vector<string> ret(res.begin(), res.end());
        return ret;
    }
private:
    TrieNode *root;
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    vector<vector<bool>> visited;
    void helper(vector<vector<char>> &board, vector<string> &words, int x, int y, 
                string str, unordered_set<string> &res, vector<vector<bool>> &visited) {
        if (searchWord(str)) {
            res.insert(str);
        }
        for (int i = 0; i < 4; i++) {
            int newX = x + dx[i];
            int newY = y + dy[i];
            if (newX >= 0 && newX < board.size() && newY >= 0 && newY < board[0].size()
                && !visited[newX][newY]) {
                str += board[newX][newY];
                if (startWith(str)) {
                    visited[newX][newY] = true;
                    helper(board, words, newX, newY, str, res, visited);
                    visited[newX][newY] = false;
                }
                str.pop_back();
            }
        }
    }
    void insertWord(string& word) {
        TrieNode *cur = root;
        int n = word.size();
        for (int i = 0; i < n; i++) {
            if (!cur->children[word[i] - 'a']) cur->children[word[i] - 'a'] = new TrieNode();
            cur = cur->children[word[i] - 'a'];
        }
        cur->isWord = true;
    }
    bool searchWord(string &str) {
        TrieNode *cur = root;
        int n = str.size();
        for (int i = 0; i < n; i++) {
            if (!cur->children[str[i] - 'a']) return false;
            cur = cur->children[str[i] - 'a'];
        }
        if (cur->isWord) return true;
        return false;
    }
    bool startWith(string &str) {
        TrieNode *cur = root;
        int n = str.size();
        for (int i = 0; i < n; i++) {
            if (!cur->children[str[i] - 'a']) return false;
            cur = cur->children[str[i] - 'a'];
        }
        return true;
    }
};
扫地机器人设计与实现——基于嵌入式系统的智能家居解决方案 本文介绍了基于嵌入式技术的扫地机器人设计与实现。通过利用STM32单片机、传感器、驱动系统等硬件组件,并结合路径规划与控制算法、远程控制等软件技术,设计出了一款具有智能避障、路径规划、自动充电等功能的扫地机器人。系统的开发不仅提高了清洁效率,也为进一步研究和优化扫地机器人提供了实践基础。 阅读详情

相关推荐

Oracle Primavera P6实战手册:从入门到精通的企业项目管理秘籍

本文详细介绍了Oracle Primavera P6在企业项目管理中的实战应用,从环境配置到高级进度控制技巧,帮助用户从入门到精通。通过WBS设计、资源优化和情景模拟等核心功能,提升项目管理效率。特别适合需要处理复杂项目和多团队协作的企业用户。

weixin_29235923的博客 280

【Leetcode】212. Word Search II

思路是DFS + Trie。想到DFS是自然的,由于要搜索多个字符串,为了避免多次重复搜索,我们可以在DFS的时候带着Trie节点一起搜,相当于同时在矩阵和Trie里搜索,当同时搜到某个单词的时候,就可以加入结果了。给定一个二维字符矩阵,再给定若干单词,问是否存在矩阵中的某条路径使得这个路径上字符组成的单词恰好就是那几个单词之一,要求返回所有满足条件的单词。路径不允许走到相同格子上。时间复杂度与具体情况有关,比较难分析。为words里单词总长度)。

数学、算法爱好者的博客 503

深入解析Lora模块的工作原理与应用场景

本文深入解析了Lora模块的工作原理与应用场景。Lora模块作为物联网领域的核心无线通信组件,凭借其独特的扩频调制与半双工通信技术,实现了远距离、低功耗的数据传输。文章详细拆解了其技术内核,包括空中唤醒等低功耗奥秘,并提供了地址、信道、空中速率等关键参数的实战配置指南。最后,探讨了Lora模块在智能家居、智慧农业、城市监测等广域物联网场景中的具体应用,为开发者提供了从理论到实践的完整参考。

weixin_29174385的博客 341

【LeetCode 面试经典150题】212. Word Search II(单词搜索 II)

Given an board of characters and a list of strings , return all words on the board.Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be

qq_43513394的博客 875

Homebrew高效升级与国内镜像源配置全攻略

本文详细介绍了如何通过配置国内镜像源(如清华、中科大、阿里云)来高效升级Homebrew,解决国内开发者访问GitHub仓库速度慢的问题。文章提供了从基础配置到永久生效的完整教程,包括常见问题解决和进阶技巧,帮助开发者大幅提升软件包管理效率。

weixin_28835551的博客 426

基于SSM的足浴管理系统(源码+开题)

研究内容: 本研究的内容主要包括以下几个方面:首先,我们需要对现有的足浴管理系统进行深入的研究和分析,了解其优缺点;最后,我们需要对新设计的系统进行评估和优化,以满足用户的需求和提升系统的使用体验。因此,开发一种基于SSM的足浴管理系统,能够有效地解决这些问题,提高足浴服务的质量和效率。研究目的: 本研究的主要目的是设计和实现一个功能完善、操作简便、用户体验良好的基于SSM的足浴管理系统。通过对系统的研究和设计,我们希望能够为足浴服务行业提供一个高效、便捷的工具,从而推动足浴服务行业的发展。

林科程序设计 1697

LeetCode - 解题笔记 - 212 - Word Search II

根据题目给出的输入大小,直接在单个词DFS上套一个遍历是肯定会超时的,因此需要简化单词的查询逻辑:前缀树。DFS的深入遍历过程可以直接关联前缀树的向下探查和向上递归的过程。的办法做了更多的剪枝。在每个节点记录尚未检查的前缀的个数,并在dfs期间更新之。如果出现了0的情况即所有的后续前缀均已经检查完毕而完全跳过后续搜索,实现更小的搜索空间。的扩展,针对一个词的判定扩展到整个列表,并找到所有的词。的实现改进,增加了一些额外的状态读写接口就可以直接用了。Solution 1的Python实现,参考了。

支锦铭的博客 385

手把手教你实现阿克曼ROS小车的运动控制

本文详细介绍了如何从零开始实现阿克曼ROS小车的运动控制。内容涵盖硬件搭建、STM32底层PID速度与舵机控制、ROS层阿克曼运动学模型解析,以及上下位机通信协议设计。通过手把手的代码示例和调试步骤,帮助机器人爱好者与开发者掌握将高级速度指令转化为小车具体动作的全流程,实现流畅的阿克曼转向控制。

weixin_29193259的博客 209

Word Search II

Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horiz...

futangxiang4793的博客 262

【006】深入了解C++中的进制转换:二进制、八进制、十进制、十六进制

二进制:0~1,以0b开头,bitset< 8 >输出。八进制:0~7,以0开头,oct输出。十进制:0~9,以数字开头,cout默认输出十进制。十六进制:0 ~ 9和A ~ F,以0x开头,hex输出,不区分正负。n进制:0~n-1。C++ 中常见的数字进制有十进制、二进制、八进制、十六进制。从十进制转换到其他进制:二进制:使用除以 2 取余数的方法,将得到的余数倒序排列即为二进制。八进制:使用除以 8 取余数的方法,将得到的余数倒序排列即为八进制。

Lion_Long的博客 2618

解析AI人工智能领域AI芯片的散热技术

当你用ChatGPT写代码、用AI生成高清图片时,背后的AI芯片可能正在“发高烧”——全球TOP500超算的平均功耗已突破10兆瓦,单颗GPU的峰值功耗超过700W(相当于3台家用空调同时运行)。本文将聚焦AI芯片的散热技术,覆盖从基础原理到前沿方案的全链条解析,帮助读者理解“散热为什么比算力更重要”。

AIGC应用创新大全的博客 945

leetcode 212. Word Search II(单词搜索 II)

给出一个2D板和字典中的单词列表,找出所有同时在2D板和字典中出现的单词。 每个单词必须由顺序相邻单元的字母构成,其中“相邻”单元是那些水平或垂直相邻的单元。同一个字母单元在一个单词中可能不会多次使用。 例如, 给出 words = [“oath”,”pea”,”eat”,”rain”] 和 board = [ [‘o’,’a’,’a’,’n’], [‘e’,’t...

liujunzxcv的专栏 2449

UNet 改进(19):与ASPP结合的图像分割模型

这个代码实现了一个改进版的UNet模型,在传统的UNet架构基础上,引入了ASPP模块来增强模型捕获多尺度上下文信息的能力。​​UNet主干网络​​:经典的编码器-解码器结构,带有跳跃连接​​ASPP模块​​:位于瓶颈层,用于提取多尺度特征。

2401_82355416的博客 885

【Lintcode】132. Word Search II

题目地址: https://www.lintcode.com/problem/word-search-ii/description 给定一个二维字符矩阵,全是英文小写字母。再给定一列单词,从矩阵的一个格子出发可以沿着上下左右走一步,这样走若干步就能形成一条路径(不能走到之前走过的格子上),这条路径上的字母形成一个单词。要求返回那列单词中存在矩阵中的路径与之相等的所有单词。 思路是Trie + DFS。如果只要搜一个单词,那可以从矩阵的每个位置开始DFS。如果是搜若干个单词,一个一个搜的话效率比较低,而如果带

数学、算法爱好者的博客 169

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

[Lintcode]132. Word Search II /[Leetcode]212. Word Search II

132. Word Search II / 212. Word Search II 本题难度: Hard Topic: Data Structure - Tire/DFS Description Given a 2D board and a list of words from the dictionary, find all words in the board. Each word mus...

siriusli1981的博客 230

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

LintCode 132. Word Search II -- Trie

Description Given a matrix of lower alphabets and a dictionary. Find all words in the dictionary that can be found in the matrix. A word can start from any position in the matrix and go left/right/up...

Choly_chen的博客 329

Lintcode132 Word Search || solution 题解

【题目描述】 Given a matrix of lower alphabetsand a dictionary.Find all words in the dictionary that can be found in the matrix. A word can start from any position in the matrix and go left/right/up/do

nekomilk的博客 261

攻克LintCode Hard难题:20道最烧脑题目完整清单与突破指南

LintCode C++11 Solutions of All 289 LintCode Problems 仓库收录了 LintCode 平台全部 289 道题目的 C++11 题解。本文从中精选 20 道 Hard 难度题目,给出完整清单与突破方法,帮你快速定位高频考点、按顺序通关 🎯 --- ## Hard 难度题目筛选:从 48 道到 20 道 整个仓库共覆盖 289 道题,其中标注

gitblog_01033的博客 244

LintCode 单词搜索 II

给出一个由小写字母组成的矩阵和一个字典。找出所有同时在字典和矩阵中出现的单词。一个单词可以从矩阵中的任意位置开始,可以向左/右/上/下四个相邻方向移动。 解法: 建立字典树存储所有要找的单词,在一个单词的最后一个字符节点上存储该单词指针 沿着字典树节点在矩阵中搜索,碰到单词的最后一个字符节点就表示找到该单词,记录到结果中 class DicNode { public: Di

zaqwsx20的专栏 1024

212. Word Search II

class Solution { private: struct TrieNode{ string s=""; TrieNode * next[26]; TrieNode(){ s=""; memset(next,0,sizeof(next)); } }; Trie

专栏 323

LeetCode 题解(92): Word Search II

题目: Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are thos

1073

深度优先搜索(DFS)优化手册

在通过搜索解决实际问题的过程中,我们是通过穷举每种情况来寻找合法解,然而在一些情况比较复杂的题目、数据量较强的题目中,由于算法的时间复杂度较高、数据规模过大,从而会导致运行超时甚至程序卡死,因此在对复杂问题的答案进行搜索时,我们应该灵活的针对每种题型设计对应的搜索规则并进行优化,通常通过设置剪枝、排除无效情况、对问题进行适当的转化等手法对搜索算法进行优化,使算法高效的执行并得出我们想要的结果。

m0_69596371的博客 1372

leetcode:word search +word searchII总结

leetcode:word search +word searchII总结①word search:给定一个m x n的矩阵A[  ['A','B','C','E'],  ['S','F','C','S'],  ['A','D','E','E']],同时给定一个单词,例如word = "ABCCED", 在矩阵中任意连续不重复走动,若可以找到word对应的单词则返回true,否则返回false.主...

xiaodidadada的博客 909

212、Word Search II (Hard)

Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those hor

wengeyiming的博客 476

word search II

Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those hor

poiop221的专栏 361
上一篇: LintCode-829. Word Pattern II (DFS难题)
下一篇: LintCode-121: Word Ladder II (经典搜索难题 BFS+DFS)
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址