Posts

unsolved java

 // Online Java Compiler // Use this editor to write, compile and run your Java code online class Main {     public static void main(String[] args) {        int [] arr={1,2,3,4,5};        //finging max and second max value         int max=Integer.MIN_VALUE;        int second_max=Integer.MIN_VALUE;        int min=arr[0];        int second_min =arr[0];        for(int i=0;i<arr.length;i++){            if(arr[i]>max){                second_max=max;                max=arr[i];            }            else if(arr[i]>second_max && arr[i]<max){                second_max=arr[i];           ...

deep logic probllems

questions: Here’s a list of intermediate-level array logic-building questions that will make you think beyond basic looping and indexing: 1. Rotation & Shifting Rotate an array k times to the left or right without using an extra array. Shift all zeroes to the end of the array while preserving the order of other elements. 2. Frequency & Counting Find the most frequent element in the array without using a map/dictionary. Count the number of pairs whose sum is equal to a given number . 3. Pattern Recognition Check if the array is a rotation of another given array. Determine if the array is a mountain array (strictly increasing then strictly decreasing). 4. Subarrays & Sums Find the maximum sum subarray (Kadane’s Algorithm). Count all subarrays with sum equal to 0 . 5. Rearrangement Challenges Rearrange the array so that positive and negative numbers alternate (order not important). Rearrange the array so that the first half is ascendin...

mistakes in problems

 // Online Java Compiler // Use this editor to write, compile and run your Java code online class Main {     public static void main(String[] args) {         int [] arr={1,2,3,1};         boolean tr=false;         int count=0;         for(int i=0;i<arr.length;i++){             for(int j=arr.length-1;j>0;j--){                 if(arr[i]==arr[j]){                   count++;                   if(count==arr.length){                       tr=true;                   }                 }             }         }         System.out.pri...

solved java

 class Main{     public static void main(String[] args){        int [] arr={1,2,3,4};        for(int i=0;i<arr.length;i++){            for(int j=0;j<arr.length;j++){                if((arr[i]+arr[j])%2==0){                    System.out.println("Even: "+arr[i]+"+"+arr[j]);                }            }        }             } } //finding maximum and minimum: import java.util.*; class SecondMax {     public static void main(String[] args) {         int[] arr = {1, 2, 3, 4, 5}; // You can test with other arrays too         int max = Integer.MIN_VALUE;         int second_max = Integer.MIN_VALUE;         for...

project.py

Image
  #Making recipt for school #Here we are importing the modules which are required from reportlab . platypus import SimpleDocTemplate , Table , Paragraph , TableStyle from reportlab . lib import colors from reportlab . lib . pagesizes import A4 from reportlab . lib . styles import getSampleStyleSheet #here we are adding the data in the recipt data = [[ 'Name of the student' , 'Roll Number' , 'Age ' , 'class' , 'paid fee' , ' payment date' , 'Balance' ]] #taking input and addind into data while True :           try :               name = input ( 'Enter name of the student: ' )               roll = int ( input ( 'Enter roll number:' ))               age = int ( input ( 'Enter age of the student: ' ))               cla = input ( 'Enter the class of the student:class ' )            ...

oops in python

#encapsulation #protected access modifier class parent :     # constructor     def __init__ ( self ):         self . _a = 9 class child ( parent ):       def __init__ ( self ):     #calling constructor in above         parent . __init__ ( self )           print ( f 'calling 1st one: { self . _a } ' )         self . _a = 7         print ( f 'calling 2nd one: { self . _a } ' )         self . _a = 5         print ( f 'calling 3rd one: { self . _a } ' )             child () # if i use print method it will show object also for example print () print ( child ()) print () #creating object and accessing it ob = parent () ob1 = child () print ( f 'accseing parent class: { ob . _a } ' ) print ( f 'accseing child class: { ob1 . _a } ' ) #it always takes updated value #o/p is: c...

Dsa in python

 #Using stack in py and in these push and pop the elements: size = int ( input ( 'Enter size of the elemnts:' )) stack = [] print ( 'Enter elements in stack:' )#inserting for i in   range ( size ):     ele = int ( input ())     stack . append ( ele ) print ( 'Elements are in stack :' )    #display for element in stack :     print ( element ) rem_v = int ( input ( 'Enter the size of elements which are removing:' )) for j in range ( rem_v ):#pop     stack . pop () print ( f 'Remainig elements in stack is : { stack } ' )                    #o/p is: Enter size of the elemnts:4 Enter elements in stack: 1 2 3 4 Elements are in stack : 1 2 3 4 Enter the size of elements which are removing:1 Remainig elements in stack is : [1, 2, 3] #Dequeue in py: from collections import deque size = int ( input ( 'Enter size of the elemnts:' )) stack = deque () print ( 'Enter elements in s...