/**
* Problem: LeetCode 3963 - Create Grid With Exactly One Path
* Difficulty: Easy
* Language: Java
* Author: CodeByTushu
*/
class Solution {
public String[] createGrid(int m, int n) {
String[] grid = new String[m];
for (int i = 0; i < m; i++) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < n; j++) {
if (i == 0 || j == n - 1) sb.append('.');
else sb.append('#');
}
grid[i] = sb.toString();
}
return grid;
}
}
"""
Problem: LeetCode 3963 - Create Grid With Exactly One Path
Difficulty: Easy
Language: Python
Author: CodeByTushu
"""
from typing import List
class Solution:
def createGrid(self, m: int, n: int) -> List[str]:
grid = []
for i in range(m):
row = []
for j in range(n):
if i == 0 or j == n - 1:
row.append('.')
else:
row.append('#')
grid.append(''.join(row))
return grid
/**
* Problem: LeetCode 3963 - Create Grid With Exactly One Path
* Difficulty: Easy
* Language: C++
* Author: CodeByTushu
*/
#include <vector>
#include <string>
using namespace std;
class Solution {
public:
vector<string> createGrid(int m, int n) {
vector<string> grid(m);
for (int i = 0; i < m; i++) {
string row = "";
for (int j = 0; j < n; j++) {
if (i == 0 || j == n - 1) {
row += '.';
} else {
row += '#';
}
}
grid[i] = row;
}
return grid;
}
};
/**
* Problem: LeetCode 3963 - Create Grid With Exactly One Path
* Difficulty: Easy
* Language: JavaScript
* Author: CodeByTushu
*/
var createGrid = function(m, n) {
const grid = [];
for (let i = 0; i < m; i++) {
let row = '';
for (let j = 0; j < n; j++) {
if (i === 0 || j === n - 1) {
row += '.';
} else {
row += '#';
}
}
grid.push(row);
}
return grid;
};