Posts

template

 **** Combinatorics **** const ll M = 1e9+7;  // default modulus // --- Basic modular operations --- ll mod(ll x, ll m = M){      return ((x % m) + m) % m;  } ll mod_add(ll a, ll b, ll m = M){      return (a + b) % m;  } ll mod_sub(ll a, ll b, ll m = M){      return ((a - b) % m + m) % m;  } ll mod_mul(ll a, ll b, ll m = M){     return ((a % m) * (b % m)) % m; // safe for small numbers } ll mod_pow(ll a, ll b, ll m = M) {     ll res = 1;     a %= m;     while(b) {         if(b & 1) res = (res * a) % m;         a = (a * a) % m;         b >>= 1;     }     return res; } // --- Modular inverse for prime modulus --- // Fermat's Little Theorem: a^(m-2) ≡ a^(-1) (mod m) ll mod_inv_prime(ll a, ll m = M){     return mod_pow(a, m - 2, m); } // --- Modular inverse for non-prime modulus --- /...

settings.json

 {     "editor.fontFamily": "'Fira Code', Consolas, monospace",     "editor.fontLigatures": true,     "editor.fontWeight": "normal",     "editor.fontSize": 18,     "editor.lineHeight": 26,     "editor.wordWrap": "on",     "editor.cursorBlinking": "smooth",     "editor.cursorStyle": "underline",     "editor.cursorWidth": 5,     "editor.cursorSmoothCaretAnimation": "off",     "editor.smoothScrolling": false,     "editor.mouseWheelSmoothScroll": false,     "workbench.reduceMotion": "on",     "editor.scrollBeyondLastLine": false,     "editor.scrollBeyondLastColumn": false,     "editor.fastScrollSensitivity": 20,     "editor.allowVariableLineHeights": false,     "files.autoSave": "onFocusChange",     "explorer.confirmDelet...

DP

64. Minimum Path Sum public class Solution {     public int MinPathSum(int[][] grid) {         int m = grid.Length, n = grid[0].Length;         int[,] dp = new int[m, n];         dp[0, 0] = grid[0][0];         for (int i = 1; i < m; i++) {             dp[i, 0] = dp[i - 1, 0] + grid[i][0];         }         for (int i = 1; i < n; i++) {             dp[0, i] = dp[0, i - 1] + grid[0][i];         }         for (int i = 1; i < m; i++) {             for (int j = 1; j < n; j++) {         ...

github so

# Full-Stack E-commerce Application using ASP.NET Core MVC This is a comprehensive E-commerce application built using ASP.NET Core MVC. It provides a robust platform for customers and administrators with features such as role-based authorization, product browsing, cart management, order handling, payment integration, and external login functionality. The application is designed for scalability, responsiveness, and ease of use. ## Screenshots _Layout (Homepage): ![Screenshot (32)](https://github.com/user-attachments/assets/92bc3927-9cd3-45fb-8cf2-a6a88c2c86b2) ## Setup Instructions Clone the Repository: ```bash   https://github.com/erytym/EcommerceMVC.git ``` Configure the App: ```bash {   "Stripe": {     "PublishableKey": "your-publishable-key",     "SecretKey": "your-secret-key"   },   "Authentication": {     "Facebook": {       "AppId": "your-app-id",       "AppSecret": "...

dotnet mastery

binary search

  Binary Search Find First and Last Position of Element in Sorted Array Search in Rotated Sorted Array Search Insert Position Search a 2D Matrix Search a 2D Matrix II Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array II Find Peak Element Search in a Binary Search Tree Insert into a Binary Search Tree Kth Smallest Element in a Sorted Matrix Kth Smallest Element in a BST Search in Rotated Sorted Array II Search in Rotated Sorted Array Find K Closest Elements Find Closest Elements Minimum Difference Between Highest and Lowest of K Scores Fixed Point Fixed Point in Array Minimum Size Subarray Sum Subarray Product Less Than K Peak Index in a Mountain Array Find Peak Element II Search in Rotated Sorted Array Search in Rotated Sorted Array II Split Array Largest Sum Search a 2D Matrix III Search a 2D Matrix LCOF Find Minimum in Rotated Sorted Array Intersection of Two Arrays II Intersection of Two Arrays Set Mismatch Find All Duplicates in an Array Find in Mountain...

DP

https://leetcode.com/problems/target-sum/solutions/455024/dp-is-easy-5-steps-to-think-through-dp-questions/ First i have to use recursion to the question then i have to go for memoization and then last i will go for top down approaches. How to find the base case? Think of the smallest valid input.  if(n==0 || w==0) return 0 as the smallest n would be 0 and also the weight for 0/1 knapsack would be 0 as well, we can not take negative weight on a bag. if i go to a store and the store has all the bigger items then i can not hold it to the bag so weight would be 0. similarly if the store has no item so n=0 Recursive function: fn (i/p) fn(smaller i/p) if the input is n then we have to go for (n-1) as the smaller input as that will work as recursion.   0/1 Knapsack Problem: 416. Partition Equal Subset Sum 474. Ones and Zeroes 494. Target Sum 1049. Last Stone Weight II 879. Profitable Schemes 1155. Number of Dice Rolls With Target Sum       Unbounded Knapsack Prob...