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/alphabet_board_path.cpp | 44 ------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 other/alphabet_board_path.cpp (limited to 'other/alphabet_board_path.cpp') diff --git a/other/alphabet_board_path.cpp b/other/alphabet_board_path.cpp deleted file mode 100644 index 874e201..0000000 --- a/other/alphabet_board_path.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// 1138. Alphabet Board Path -#include "leetcode.h" - -/* - * on an alphabet board, we start position [0,0], corresponding to character - * 'board[0][0]'. here, 'board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", - * "z"]' as show in the diagram (see page). return a sequence of moves that - * makes our answer equal to 'target' in the minimum numbe of moves. (in any - * order/path) - */ - -class Solution { -public: - string alphabetBoardPath(string target) { - unordered_map> mp; - for (int i = 0; i < 26; ++i) - mp[i + 'a'] = {i / 5, i % 5}; - target = 'a' + target; - string path; - int dx = 0, dy = 0; - for (int i = 1; i < target.size(); ++i) { - auto curr = mp[target[i]]; - auto prev = mp[target[i - 1]]; - dx = curr.first - prev.first; - dy = curr.second - prev.second; - if (dy < 0) - path += string(-dy, 'L'); - if (dx < 0) - path += string(-dx, 'U'); - if (dy > 0) - path += string(dy, 'R'); - if (dx > 0) - path += string(dx, 'D'); - path += '!'; - } - return path; - } -}; - -int main() { - Solution boj; - cout << boj.alphabetBoardPath("leet") << endl; // expect: DDR!UURRR!!DDD! - cout << boj.alphabetBoardPath("code") << endl; // expect: RR!DDRR!UUL!R! -} -- cgit v1.2.3