Posts

Showing posts from September, 2025

Java

  //candy problem import java . util . Arrays ; import java . util . Scanner ; public class Main {   public static void main ( String [] args ) {     System . out . println ( "Hello World" );     @ SuppressWarnings ( "resource" )     Scanner input = new Scanner ( System . in );         int n = input. nextInt ();     int [] arr = new int [n];     boolean [] ansarr = new boolean [n];     ansarr[ 0 ] = true ;       for ( int i = 0 ; i < n; i ++ ) {         arr[i] = input. nextInt ();         arr[i] = arr[i] + 3 ;       }           for ( int i = 1 ; i < ansarr. length ; i ++ ) {         if (arr[i] > arr[i - 1 ]) {           ansarr[i] = true ;         }         else {      ...

Node js

  const file = require ( 'fs' ); const result = file . writeFileSync ( "hello.txt" , "Hello my name is aditya" ); console . log ( result ); //hello.js console . log ( "hello" ); const math = require ( "./math" ); //console.log(math.add(3,5)); const value = math. add ( 3 , 5 ); console . log ( value ); //maths export function add ( a , b ){   return a + b ; } function sub ( a , b ){   return a - b ; } //we have to export functions to use them in other files because we run the server with only one file module . exports = { add , sub }; //server.js const http = require ( "http" ); const fs = require ( 'fs' ); const myserver = http . createServer (( req , res ) => { const log = ` ${ Date . now ()} : ${ req . url } :The request recieved \n ` ; fs . appendFile ( 'serverlog.txt' , log , ( req , res ) => { })   // console.log("request recieved");   switch ( req .url){   ...