From 76ff8d5f4f04b0a67b18b6df6053dbc605d6369e Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 26 Jun 2024 22:51:12 +0530 Subject: [PATCH 1/4] add dailyTemperatures.js --- dailyTemperatures.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 dailyTemperatures.js diff --git a/dailyTemperatures.js b/dailyTemperatures.js new file mode 100644 index 0000000..4c9e654 --- /dev/null +++ b/dailyTemperatures.js @@ -0,0 +1,17 @@ +/** + * @param {number[]} temperatures + * @return {number[]} + */ +var dailyTemperatures = function(temperatures) { + const stack = []; + const result = new Array(temperatures.length).fill(0); + + for(let i =0;i0 && temperatures[i] > temperatures[stack[stack.length -1]]){ + const idx = stack.pop(); + result[idx] = i - idx + } + stack.push(i); + } + return result +}; \ No newline at end of file From 13172decd102a5e418cc34cfa1a1346f05b5aa9c Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 29 Jun 2024 13:06:51 +0530 Subject: [PATCH 2/4] add findWords.js --- findWords.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 findWords.js diff --git a/findWords.js b/findWords.js new file mode 100644 index 0000000..63c270f --- /dev/null +++ b/findWords.js @@ -0,0 +1,50 @@ +/** + * @param {character[][]} board + * @param {string[]} words + * @return {string[]} + */ +var findWords = function(board, words) { + let result = [] + let root = buildTrie(words) + + for(let i = 0; i< board.length ;i++){ + for(let j=0;j board.length -1 || j > board[0].length-1) return + if(!node[board[i][j]]) return + + let c = board[i][j] + board[i][j] = '#' + + dfs(node[c],i+1,j,result,board) + dfs(node[c],i-1,j,result,board) + dfs(node[c],i,j+1,result,board) + dfs(node[c],i,j-1,result,board) + board[i][j] = c + +} + +function buildTrie(words){ + let root = {} + + for(let word of words){ + let currNode = root + + for(let char of word){ + if(!currNode[char]) currNode[char] = {} + currNode = currNode[char] + } + currNode.word = word + } + return root +} \ No newline at end of file From 8c674b906fed6b9180c8740befe32ee0699c8e70 Mon Sep 17 00:00:00 2001 From: Harsh Vaidya Date: Sun, 30 Jun 2024 15:24:20 +0530 Subject: [PATCH 3/4] Create npm-publish-github-packages.yml --- .../workflows/npm-publish-github-packages.yml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/npm-publish-github-packages.yml diff --git a/.github/workflows/npm-publish-github-packages.yml b/.github/workflows/npm-publish-github-packages.yml new file mode 100644 index 0000000..0f838d5 --- /dev/null +++ b/.github/workflows/npm-publish-github-packages.yml @@ -0,0 +1,36 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-gpr: + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://npm.pkg.github.com/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} From 97db97a5c01e248f16b24aeef48bf6a83f34453f Mon Sep 17 00:00:00 2001 From: Harsh Vaidya Date: Sun, 30 Jun 2024 15:24:41 +0530 Subject: [PATCH 4/4] Create npm-grunt.yml --- .github/workflows/npm-grunt.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/npm-grunt.yml diff --git a/.github/workflows/npm-grunt.yml b/.github/workflows/npm-grunt.yml new file mode 100644 index 0000000..1f2d88e --- /dev/null +++ b/.github/workflows/npm-grunt.yml @@ -0,0 +1,28 @@ +name: NodeJS with Grunt + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Build + run: | + npm install + grunt