This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
double getMinDistSum(vector<vector<int>>& positions) { | |
double minX = 200, maxX = -1, minY = 200, maxY = -1; | |
for (const auto& p : positions) { | |
double x = p[0], y = p[1]; | |
minX = min(minX, x); | |
maxX = max(maxX, x); | |
minY = min(minY, y); | |
maxY = max(maxY, y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Alice认为整数 x是K-wolf数,如果x的十进制表示中的每k个相邻数字都是不同的。 | |
给定(l,r,k),请计算在[l,r]范围内有多少个K-Wolf数。 | |
样例 | |
样例 1: | |
输入: l=1,r=1,k=2 | |
输出: 1 | |
解释: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 题目描述: | |
给定一个 n * m 的迷宫 maze, 其中: | |
. 表示空地 | |
S 表示起点 | |
T 表示终点 | |
* 表示障碍物 | |
0~9 表示不同的宝物 | |
请问从起点开始, 在拿到所有宝物之后走到终点, 最少需要多少步? 如果无法拿到全部的宝物并走到终点, 返回 -1. | |
样例 | |
样例 1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <unordered_map> | |
using namespace std; | |
class TrieNode { | |
public: | |
TrieNode() { | |
next[0] = next[1] = 0; |