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
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 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
### 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 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
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: | |
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: | |
bool check_deadends(unordered_set<string>& deadends, const string & target){ | |
if(deadends.find(target) != deadends.end()) return true; | |
deadends.insert(target); | |
return false; | |
} | |
bool check_target(const string & a, const string & b){ | |
return (a==b); |
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: | |
bool PredictTheWinner(vector<int>& nums) { | |
int length = nums.size(); | |
std::vector< std::vector<int> > s(length, std::vector<int> (length)); | |
for(int l = 0; l < length; l++){ | |
for(int i=0; i < length - l; i++){ | |
if(l==0) s[i][l] = nums[i]; | |
else if (l==1) s[i][l] = max(nums[i], nums[i+1]); | |
else if (l==2) s[i][l] = max(nums[i] + min(nums[i+1], nums[i+2]), |
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: | |
def PredictTheWinner(self, c): | |
""" | |
:type nums: List[int] | |
:rtype: bool | |
""" | |
r = len(c) | |
t = sum(c) | |
s = [[0 for i in range(r)] for j in range(r)] | |
for l in range(r): # l is for the length - 1 |