EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Java data structure practice programs for leetcode

Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.   Example 1: Input: haystack = “sadbutsad”, needle = “sad” Output: 0 Explanation: “sad” occurs at index 0 and 6. The first occurrence is at index 0, so we […]

Java practice programs in data structures

Given a non-empty array of integers nums[], every element appears twice except for one. Find that single one.   Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4     ——————————— public class Main { public static int SingleNumber(int[] nums)//2,2,1 { int result = 0; for (int num : nums) […]

Java practice programs for leetcode

Given an integer array nums[], rotate the array to the right by k steps, where k is non-negative.   Example 1: Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1,2,3,4,5,6] rotate 2 steps to the right: [6,7,1,2,3,4,5] rotate 3 steps to the right: [5,6,7,1,2,3,4]   ————————————————– class […]

Java data structures in binary search

Binary search:   1–1000 find=532?   min=1 max=1000————>1+1000/2==>500 ———————————>avg=500   1)avg? 500 2)532<avg?———————–>No   so, min=avg+1==>501 max=>1000——–>501+1000/2====>avg==>750   3)avg?750 4)532<750———————–>yes so, min=501 max=>avg-1——–>501+749/2====>avg==>1250/2===>625   5)avg?625 6)532<625———————–>yes so, min=501 max=>avg-1——–>501+624/2====>avg=====>562.5   7)avg?562 8)532<562———————–>yes so, min=501 max=>avg-1——–>501+561/2====>avg=====>531   9)avg?531 10)532<531———————->No   so, min=avg+1==>532 max=>561——–>532+561/2====>avg==>546   11)avg?546 12)532<546———————->yes so, min=532 max=>avg-1——–>532+545/2====>avg=====>538   13)avg?538 14)532<538———————->yes so, min=532 max=>avg-1——–>532+537/2====>avg=====>534   […]

Java practice programs for leetcode

Create an interface Printable with a method print(), implement this interface in classes Document and photo   interface Printable { void print(); }   class Document implements Printable { void print() { System.out.println(“Document printed”); } }   class Photo implements Printable { void print() { System.out.println(“Photo printed”); } }   class Main { public static […]

Java code to create rectangle with attributes

Create a class Rectangle with attributes length and width. Use a constructor to initialize values and calculate the area   class Rectangle { int length, width;   Rectangle(int l,int w) { length=l; width=w; }   int area() { return length*width; } } class Main { public static void main(String args[]) { Rectangle r=new Rectangle(10,2); System.out.println(“Area=” […]

Java practice programs to create student details form

Create a student class with name, roll number. Use a constructor to initialize and display the student details     class Student { String name; int rollNo;   Student(String name,int rollNo) { this.name=name; this.rollNo=rollNo; }   void display() { System.out.println(name); System.out.println(rollNo); } } class Main { public static void main(String args[]) { Student s1=new Student(“John”,101); […]

Java code to find bank details

Create a class BankAccount with attributes account holder name,account number and balance. Include a methods for deposit and withdrawal   class BankAccount { String Holdername; int AccountNo; int Balance;   void deposit(int amount)amount=3000 { Balance+=amount;//8000 }   void withdrawal(int amount)//1000 { if(amount<=Balance)//1000<=8000 Balance-=amount;//7000 else System.out.println(Insufficient Balance”); }   void display() { System.out.println(Balance);//7000 }   } […]

Java code to find student data

Create a student class with attributes name, roll number and marks. create 2 student objects and display their details   class Student { String name; int rollNo; int marks;   void display() { System.out.println(“Name=” +name); System.out.println(“Roll no=” +rollNo); System.out.println(“Marks=” +marks); }   } class Main { public static void main(String args[]) { Student s1=new Student(); […]

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer