Posts

week2 DSA 05/04, prefix, frequency Array

Image
problem statement: https://leetcode.com/problems/find-the-highest-altitude/description/ //highest altituade class Solutation { public: int largestAltitued (vecotr <int> & gain ) {  int n = gani.size(); vector<int>alt(int,0); for(int i = 1; i<= n; i++;) { alt[i] = alt [i-1] + gain[i-1]; } int max_el = *max_elemenet(alt.begin(), alt.end()); reutrn max_el; } };                                                      **normal way of for loops to count frequency** #include <iostream> #include <string> using namespace std; int main() {     string str = "hello";     int freq[26] = {0}; // Array to store frequency of each letter     // Calculate frequency of each character     for (char c : str) {         freq[c - 'a']++; // Increment the count f...

Week 1, DSA 02/04, array

 PPT:- https://projects.100xdevs.com/tracks/dsa/dsa1 DSA stands for data Structure and Algorithms. Data Structures:  means the way some data is stored for example: we can store data as lists or in a stack or as a tree, All of these are examples of data structures, Algorithms is a set of steps you need to follow to solve some problem. Either the set fo steps is known {example, sorting, DFS etc} or you derive the set of steps using first principles and logical thinking CP stands for Competitive Programing. it is a sport where competitors solve DSA ICPC IOI code jam local contests Array :  Collection of elements of some (any) type is called an array /list int f(int x, vector<int>& nums) { //count of all the pairs (i,x) where A[i] = A[x] and i != x and A is the prefix till x // A =  [nums[0], nums[1], ......, nums[x]] int count = 0; for(int i = 0 ; i< ; i++) { if (nums[i] = nums[x]) { count +=1; } } return count; } int numIdenticalParis(vector<int>...

week 15.1 docker, in project IDX setUp

/* create and setup as mention on step1,2,3,4,5 //if you want to create your won docker project      1) clone your prjoect or write your project      2) Dockerfile  //create a dockerfile in your root of project diricitory and write this inside your dockerfile. inside the Dockerfile mention all commands that will required before start you program. all snippet code mention bellow. a) FROM node:22-alpine   #base image which will retrive by docker registry.           a) FROM node:20   #base image which will retrive by docker registry. b) WORKDIR /app     # working diricitory c) COPY . .      #COPY OVER FILE d) RUN npm install  #run command to build the program d.1) RUN npm run build // e) EXPOSE 8080      # EXPOSE PORT #command to run the application              f)    CMD ["node", "dist/index.js" ]...

form project form scratch full backend-frontend(fullStack)

1. npm init 2. npm install express 3. npm install pg //for postgrace 4. npm install dotenv 5. npm install cors const express = require ( 'express' ); const pg = require ( 'pg' ); const { Pool } = require ( 'pg' ); require ( 'dotenv' ). config (); const cors = require ( 'cors' ) const app = express (); //this is our app or interface of express const port = 8080 ; // Adjust port number as needed const pool = new pg. Pool ({ connectionString: process.env. DATABASE_URL , ssl: { rejectUnauthorized: false } }); // Function to create table if it doesn't exist const createTable = async () => { const client = await pool . connect (); try { const createTableQuery = ` CREATE TABLE IF NOT EXISTS your_table ( id SERIAL PRIMARY KEY, name VARCHAR(100), age INTEGER ); ` ; await client . query ( createTableQuery ); console . log ( "Table 'your_table...

week6.3 useState, usEffect, useMemo, useCallback, memo, useRef

 reconciliation  reconciliation is useState 1. import useState form react lib 2. write cosnt var which take two input (sate,  setState) satte mean if count 7 then state will be 7 then i press button and added 7+1 = 8 ; setSate tell state that you need to update yourself from 7 to 8; based on user entery. 3. the initial's it by 0 that help to store exact number to store eg: if i initial's it by 1 and the user update  state by 2 then state value need 2 but you got 3 thats wrong thats why .........! syntax:  import { useState } from 'react' //write this componenet inside the app OR another function const [count, setCount] = useState(0) then use this componenet and write you logic /============================================ useEffect: The useEffect Hook allows you to perform side effects in your components and stop unnecessary rendering, rerander when dependency change only. Some examples of side effects are: fetching data, directly updating the DOM, and timers. u...

week 7.1 routeing, lazy component, prop drilling, contextAPI

//create a react project 1. npm install 2. npm install react-router-dom  //for using react routing //create page OR component folder inside create 2page landing.jsx and dashboard.jsx ----------------------------------------------------------- //then we use navigation to use client side route / first import usenavigation import { BrowserRouter, Routes, Route, useNavigate } from 'react-router-dom'; // definre up from the syntx you write const navigate = useNavigate(); then syntax**   <button onClick={() => {           navigate("/");         }}>Landing</button> -------------------------------------------------------------- +++++++++++++++++++++++++++++ now we will do only client side routing do not hard refresh like before we did //then we use navigation to use client side route / first import usenavigation import { BrowserRouter, Routes, Route, useNavigate } from 'react-router-dom'; // definre up from the syntx you...

week12.1 aws frontend deploing, serve

https://projects.100xdevs.com/tracks/w5E6PT2t0IyOFM3bZxcM/aws-fe-1  1. when you devloping your project to run you react project  // npm run dev    1. after development project you need to buil you code react into simple html use this command // npm run build 1.then serve you code to run your code // npm install -g serve 1. then go to dist folder and run the command // serve