Posts

fetch data

  import   React , {  useState , useEffect  }  from   'react' ; import   './Box.css' ; function   Box () {      const  [ results ,  setCount ] =  useState ([]);      async   function   M1 () {      const   response  =  await   fetch ( 'https://api.unsplash.com/search/photos?page="+"&query="+cars+"&client_id=HKkVWrW8SC28UJgRPPZ-z0UfJVSH4a7Ym2qoLCa35fY' );           const   data  =   await   response . json ();      setCount ( data . results );      console . log ( data . results );        }      useEffect (()  =>  {          M1 ();   },[]);             return ...

DS/Alogo Job Ready

 1)Check prime  Is A Number Prime concept:- no divide hona chiya khud sa ya fir apena app sa toa n  ko n number tak divde karka dekho then agar count 2 aya means 1 or apena app sa toa number is prime easy haa 1)for loop ; 2)int count = 0; 3)if check div horaha haa ke nahi t%i == 0; 4)if count==2 then prime; public class HelloWorld{      public static void main(String []args){         System.out.println("Hello World");                  int t  = 114;         int count = 0;                  for(int i = 1;i<=t;i++){             if(t%i==0){                 count++;             };         };                          if(count==2){     ...

Remote websites

click   worktech remoteio angellist sidehusel wwr yellow Dog

Green and Red

  class Solution { static int RedOrGreen ( int N , String S ) { int Red = 0 , Green = 0 ; for ( int i = 0 ; i < N ; i ++) { if ( S . charAt ( i ) == 'R' ) Red ++; else Green ++; } return Math . min ( Red , Green ); } }

new

 App.js import   react , { useEffect ,  useState } from   "react" ; import   './App.css' ; import   Header   from   "./components/Header" ; import   Recipes   from   "./components/Recipes" ; import   Axios   from   "axios" ; function   App () {    const  [ search ,  setSearch ] =  useState ( "Icecream" );    const  [ recipes , setRecipes ] =  useState ([]);    useEffect (() => {       getRecipe ();   },[]);       const   getRecipe  =  async () => {      const   res  =  await   Axios . get ( `https://api.edamam.com/search?q=${ search }&app_id=${ APP_ID }&app_key=${ APP_KEY }&from=0&to=3&calories=591-722&health=alcohol-free` )      setRecipes ( res . data . hits )   }  ...

sorted Array

Image
 // Java implementation of QuickSort import java.io.*; class GFG{ // A utility function to swap two elements static void swap(int[] arr, int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } /* This function takes last element as pivot, places the pivot element at its correct position in sorted array, and places all smaller (smaller than pivot) to left of pivot and all greater elements to right of pivot */ static int partition(int[] arr, int low, int high) { // pivot int pivot = arr[high]; // Index of smaller element and // indicates the right position // of pivot found so far int i = (low - 1); for(int j = low; j <= high - 1; j++) { // If current element is smaller // than the pivot if (arr[j] < pivot) { // Increment index of // smaller element i++; swap(arr, i, j); } } swap(arr, i + 1, high); return (i + 1); } /* The main function that implements QuickSort arr[] --> Array to be sort...

Insertion Sort

Image
  // Java program for implementation of Insertion Sort class InsertionSort { /*Function to sort array using insertion sort*/ void sort(int arr[]) { int n = arr.length; for (int i = 1; i < n; ++i) { int key = arr[i]; int j = i - 1; /* Move elements of arr[0..i-1], that are greater than key, to one position ahead of their current position */ while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } } /* A utility function to print array of size n*/ static void printArray(int arr[]) { int n = arr.length; for (int i = 0; i < n; ++i) System.out.print(arr[i] + " "); System.out.println(); } // Driver method public static void main(String args[]) { int arr[] = { 12, 11, 13, 5, 6 }; InsertionSort ob = new InsertionSort(); ob.sort(arr); printArray(arr); } } /* This code is contributed by Rajat Mishra. */