Skip to content

Commit 448dfdb

Browse files
committed
0818
1 parent 7e5fe24 commit 448dfdb

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {number[][]} grid
3+
* @param {number} row
4+
* @param {number} col
5+
* @param {number} color
6+
* @return {number[][]}
7+
*/
8+
var colorBorder = function(grid, row, col, color) {
9+
function doBFS(r,c,color,prevColor){
10+
const visited=Array.from({length:grid.length},Array(grid[0].length).fill(false);)
11+
const queue=[[row,col]];
12+
if(prevColor===grid[r][c]){
13+
visited[r][c]=true;
14+
15+
}
16+
}
17+
doBFS(row,col,color)
18+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {string[]} words
3+
* @param {number[]} weights
4+
* @return {string}
5+
*/
6+
var mapWordWeights = function(words, weights) {
7+
let result=""
8+
for(const word of words){
9+
let sum=0;
10+
for(let i=0;i<word.length;i++){
11+
const char=word.charCodeAt(i);
12+
sum+=weights[char-"a".charCodeAt(0)];
13+
}
14+
result+=String.fromCharCode("z".charCodeAt(0)-(sum%26));
15+
}
16+
17+
return result
18+
};

0 commit comments

Comments
 (0)