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
class Solution { | |
public: | |
vector<vector<int>> updateMatrix(vector<vector<int>>& matrix) { | |
int n = matrix.size(); | |
int m = 0; | |
if(n>0) m = matrix[0].size(); | |
int max_dist = 100000; | |
queue< pair<int, int> > q; | |
for(int i = 0; i < n; i++){ |
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
class Solution { | |
public: | |
vector<vector<int>> updateMatrix(vector<vector<int>>& matrix) { | |
int n = matrix.size(); | |
int m = 0; | |
if( n > 0 ) m = matrix[0].size(); | |
int max_dist = 100000; | |
vector< vector<int> > dist(n, vector<int> (m, max_dist)); | |
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
class Solution { | |
public: | |
int largestRectangleArea(vector<int>& heights) { | |
int space = 0; | |
int maxh = 0; | |
int n = heights.size(); | |
stack<int> s; | |
int i = 0; | |
int max_space = 0; | |
while(i<n){ |
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
### Visualize your network's feature maps here. | |
### Feel free to use as many code cells as needed. | |
# image_input: the test image being fed into the network to produce the feature maps | |
# tf_activation: should be a tf variable name used during your training procedure that represents the calculated state of a specific weight layer | |
# activation_min/max: can be used to view the activation contrast in more detail, by default matplot sets min and max to the actual min and max values of the output | |
# plt_num: used to plot out multiple different weight feature map sets on the same block, just extend the plt number for each new feature map entry | |
def outputFeatureMap(image_input, tf_activation, activation_min=-1, activation_max=-1 ,plt_num=1): | |
# Here make sure to preprocess your image_input in a way your network expects | |
# with size, normalization, ect if needed |
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
class Solution { | |
public: | |
int ladderLength(string beginWord, string endWord, vector<string>& wordList) { | |
queue<string> q; | |
unordered_set<string> m, dict; | |
q.push(beginWord); | |
m.insert(beginWord); | |
for(const auto & it : wordList) | |
dict.insert(it); | |
int level = 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
class STNode{ | |
public: | |
long l, r, m; | |
bool tracked; | |
STNode * lnode, * rnode; | |
STNode(int ll, int rr):l(ll), r(rr), lnode(nullptr), rnode(nullptr){ | |
m = (l+r)/2; | |
tracked = false; | |
} |
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
class STNode{ | |
public: | |
long l, r, m; | |
bool tracked; | |
shared_ptr<STNode> lnode, rnode; | |
STNode(int ll, int rr):l(ll), r(rr), lnode(nullptr), rnode(nullptr){ | |
m = (l+r)/2; | |
tracked = false; | |
} | |
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 an interval. | |
* struct Interval { | |
* int start; | |
* int end; | |
* Interval() : start(0), end(0) {} | |
* Interval(int s, int e) : start(s), end(e) {} | |
* }; | |
*/ |
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
#include<string> | |
#include<iostream> | |
#include<vector> | |
using namespace std; | |
class ShortPalindromes{ | |
public: | |
string solve(const string & s, int i, int j, |
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
class Vector2D { | |
private: | |
vector<vector<int>>::iterator row, iBegin, iEnd; | |
vector<int>::iterator col; | |
public: | |
Vector2D(vector<vector<int>>& vec2d) { | |
iBegin = row = vec2d.begin(); | |
iEnd = vec2d.end(); | |
if(vec2d.size()) | |
col = row->begin(); |