This file contains hidden or 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
| void dfs(char** grid, int rowMax, int colMax, int currentRow, int currentCol) { | |
| if (currentRow >= rowMax || currentRow < 0 || currentCol >= colMax || currentCol < 0 || grid[currentRow][currentCol] != '1') return; | |
| grid[currentRow][currentCol] = '0'; | |
| dfs(grid, rowMax, colMax, currentRow + 1, currentCol); | |
| dfs(grid, rowMax, colMax, currentRow - 1, currentCol); | |
| dfs(grid, rowMax, colMax, currentRow, currentCol + 1); | |
| dfs(grid, rowMax, colMax, currentRow, currentCol - 1); | |
| } |
This file contains hidden or 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
| void dfs(char** grid, int rowMax, int colMax, int currentRow, int currentCol) { | |
| if (currentRow >= rowMax || currentRow < 0 || currentCol >= colMax || currentCol < 0 || grid[currentRow][currentCol] != '1') return; | |
| grid[currentRow][currentCol] = '0'; | |
| dfs(grid, rowMax, colMax, currentRow + 1, currentCol); | |
| dfs(grid, rowMax, colMax, currentRow - 1, currentCol); | |
| dfs(grid, rowMax, colMax, currentRow, currentCol + 1); | |
| dfs(grid, rowMax, colMax, currentRow, currentCol - 1); | |
| } |
This file contains hidden or 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
| bool visit(int** rooms, int* roomsColSize, int roomNo, int* checkCountPtr, int* checkRooms, int roomSize) { | |
| if (!checkRooms[roomNo]) { | |
| checkRooms[roomNo] = 1; | |
| *(checkCountPtr) += 1; | |
| } | |
| if (*checkCountPtr == roomSize) | |
| return true; | |
This file contains hidden or 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
| /** | |
| * Definition for a binary tree node. | |
| * struct TreeNode { | |
| * int val; | |
| * struct TreeNode *left; | |
| * struct TreeNode *right; | |
| * }; | |
| */ | |
This file contains hidden or 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
| int visit(struct TreeNode* node, int L, int R) { | |
| if (!node) return 0; | |
| int left = 0; | |
| int right = 0; | |
| left = visit(node->left, L, R); | |
| right = visit(node->right, L, R); | |
| if (node->val >= L && node->val <= R) | |
| return left + right + node->val; |
This file contains hidden or 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
| /** | |
| * Definition for a binary tree node. | |
| * struct TreeNode { | |
| * int val; | |
| * struct TreeNode *left; | |
| * struct TreeNode *right; | |
| * }; | |
| */ | |
This file contains hidden or 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
| /** | |
| * Definition for a binary tree node. | |
| * struct TreeNode { | |
| * int val; | |
| * struct TreeNode *left; | |
| * struct TreeNode *right; | |
| * }; | |
| */ | |
This file contains hidden or 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
| struct TreeNode* invertTree(struct TreeNode* root){ | |
| if (root) { | |
| struct TreeNode* tmp = root->left; | |
| root->left = invertTree(root->right); | |
| root->right = invertTree(tmp); | |
| } | |
| return root; | |
| } |
This file contains hidden or 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
| /** | |
| * Definition for a binary tree node. | |
| * struct TreeNode { | |
| * int val; | |
| * struct TreeNode *left; | |
| * struct TreeNode *right; | |
| * }; | |
| */ | |
| void invert (struct TreeNode *node) { |
This file contains hidden or 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
| import random | |
| import formatCSV | |
| import financeToken | |
| import StockNJ | |
| import TradingRule | |
| from IndicatorKdRuleInPassivation import * | |
| import copy | |
| DECIMAL_BIT_LEN = 4 | |
| ALPHA_BIT_LEN = 3 |