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
from tensorflow.keras.preprocessing.image import ImageDataGenerator | |
from tensorflow.keras.optimizers import RMSprop | |
import matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
import os | |
import tensorflow as tf | |
import zipfile | |
base_dir = '/home/jyotinder/Programming/DeepLearning/dataset/dogs-vs-cats' | |
train_dir = os.path.join(base_dir, 'train') |
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
// https://leetcode.com/problems/subarray-sum-equals-k/ | |
class Solution { | |
public: | |
int subarraySum(vector<int> &nums, int k) | |
{ | |
unordered_map<int, int> map; | |
int count = 0; | |
// maintains sum of elements so far | |
int curr_sum = 0; |
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
// https://youtu.be/9PC2r6MAw1Q | |
// https://leetcode.com/problems/dungeon-game/ | |
class Solution | |
{ | |
public: | |
int calculateMinimumHP(vector<vector<int>> &dungeon) | |
{ | |
if (dungeon.size() == 0 || dungeon[0].size() == 0) | |
return 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 Solution { | |
public: | |
vector<int> twoSum(vector<int>& nums, int target) { | |
unordered_map<int, int> mp; | |
for(int i = 0; i < nums.size(); ++i) { | |
int complement = target - nums[i]; | |
if(mp.find(complement) != mp.end()) { | |
return {mp[complement], 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
// https://leetcode.com/problems/3sum/ | |
// Explanation: | |
// https://youtu.be/6WsddbKA_vg | |
class Solution { | |
public: | |
vector<vector<int>> threeSum(vector<int>& nums) { | |
vector<vector<int>> res; | |
if(nums.size() < 3) { | |
return res; | |
} |
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 numTrees(int n) { | |
vector<int> G(n + 1, 0); | |
G[0] = 1, G[1] = 1; | |
// Iterating for different values of N, in Bottom Up Approach | |
for(int i = 0; i <= n; ++i) { | |
// Looking at each case with all nodes as roots |
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>> fourSum(vector<int> &nums, int target) | |
{ | |
vector<vector<int>> res; | |
if (nums.size() < 4) | |
{ | |
return res; | |
} |
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 minDistance(string word1, string word2) { | |
vector<vector<int>> dp(word2.size() + 1, vector<int> (word1.size() + 1)); | |
/* | |
* Going downwards in the first column (for "" as the first string), | |
* we're performing the insert operation | |
* And the number of inserts to turn an empty string to a | |
* string with length L is L |
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 exist(vector<vector<char>> &board, string word) | |
{ | |
for (int i = 0; i < board.size(); ++i) | |
{ | |
for (int j = 0; j < board[0].size(); ++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 Solution { | |
public: | |
int arrangeCoins(int n) { | |
long n_long = (long) n; | |
long left = 1, right = n_long; | |
while(left <= right) { | |
long mid = left + (right - left) / 2; // (left + right) / 2 | |
if(mid * (mid + 1) / 2 <= n_long) { |
OlderNewer