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
// 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: | |
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://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
// 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
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') |
NewerOlder