Java Add Border
public class Solution {
public static String[] addBorder(String[] picture) {
int width = picture[0].length() + 2;
String border = "*".repeat(width);
String[] result = new String[picture.length + 2];
result[0] = border;
for (int i = 0; i < picture.length; i++) {
result[i + 1] = "*" + picture[i] + "*";
}
result[result.length - 1] = border;
return result;
}
}
This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.