Search Results


9 matches found for 'matrix'

Rotate a 2D Matrix

... jsav = new JSAV("set"); jsav.label("Before rotation").css({"color": "gray"}); var m = jsav.ds.matrix([[0, 1, 2], [3, 4, 5], [6, 7, 8]]); jsav.label("After rotation").css({"color": "green"}); var n = jsav.


Algorithm Handbook

... Consider swapping elements to remove elements. 2D Arrays Don't ever create a 2d matrix in Python like this: matrix = [[0] * len(col)] * len(row)] You are making shallow lists here which points to the same sub-list as the first one.


Flip adjacent colors in a 2D matrix

... with x, y coordinates Approach Suppose that the entry point is in dead center of the 2D matrix \(n \times m\), where \(n = 10000\) and \(m = 10000\). If we use DFS from the entry point, at the worst case we may end up traversing to the very top of the 2D array first, only to come back all the way down to the bottom of the 2D array, and repeating this up-down movement numerous times.


Find the maximum min path

Problem Given a matrix of integers, there are many paths to take from the top left to the bottom right. For each path, the smallest number in the path is the min of the path. Of all the min paths, find the maximum min path.


CNN - Convolutional Neural Networks

... (features). How it works In a nutshell the CNN layer does convolution on the original matrix to output a shrunken down version of the matrix with aggregated weights.


Find a path in a maze from start to finish

... of the end point. An invalid block would be any block that has a value of False in the maze matrix, or any block with invalid coordinates (i.e. an x-coordinate of -1 means that it is not within the dimensions of the matrix).


Algorithm Interview Problems

... k sorted lists Graphs Find a path in a maze from start to finish Flip colors in a matrix Search Search in a rotated sorted array Find the Duplicate Number Greedy Algorithms Queue Reconstruction By Height Trie Build a Trie in Python Invariant Compute the max.


RNN - Recurrent Neural Networks

... 1: Use activation functions (i.e. Sigmoid, tanh, ReLU) Solution 2: Initialize weights to identity matrix and bias to 0, to help prevent shrinking weights to 0 Solution 3: Add more logic to \(h_t\) by adding some gating to control what information is passed through.


Machine Learning Basics

... ** features - (200, 3) features.T - (3, 200) We transpose the input matrix, swapping cols and rows to make vector math easier ** for feature in features.