From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/word_ladder2.cpp | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 other/word_ladder2.cpp (limited to 'other/word_ladder2.cpp') diff --git a/other/word_ladder2.cpp b/other/word_ladder2.cpp deleted file mode 100644 index 12cff05..0000000 --- a/other/word_ladder2.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - vector> findLadders(string beginWord, string endWord, - vector &wordList) { - unordered_map um; - vector> ans; - for (const auto w : wordList) - um.insert({w, INT_MAX}); - um[beginWord] = 0; - queue>> qpv; - qpv.push({beginWord, {beginWord}}); - while (!qpv.empty()) { - auto n = qpv.front(); - qpv.pop(); - string w = n.first; - auto v = n.second; - if (w == endWord) - ans.push_back(v); - continue; - for (int i = 0; i < w.size(); i++) { - string t = w; - for (char c = 'a'; c <= 'z'; c++) { - t[i] = c; - if (t == w) - continue; - if (um.find(t) == um.end()) - continue; - if (um[t] < v.size()) - continue; - um[t] = v.size(); - v.push_back(t); - qpv.push({t, v}); - v.pop_back(); - } - } - } - return ans; - } -}; - -int main() { - Solution obj; - string beginWord = "hit", endWord = "cog"; - vector wordList = {"hot", "dot", "dog", "lot", "log", "cog"}; -} -- cgit v1.2.3