Arrays- 2| Taking Input, Array Reference, Cloning and Copy |Lecture 15| Java & DSA Foundation Course

preview_player
Показать описание
As promised, here is the second lecture in the series of Array Basics.
In this class, Manvi mam will cover the intricacies of array references, cloning, concept of deep and shallow copy and much more!
That is not all!
She is also going to solve some practice problems for absolute clarity of the concepts!
Do not miss it!

Are you finding the classes helpful?
Stay tuned for more!

Access the notes and assignments for this class for free at :

If you are joining us late, to know more about PWSkills & plans :

▶️ PW Skills LinkedIn Channel -

Timestamps:
00:00 - Introduction
00:22 - Recap of the previous lecture
11:32 - Taking array input in Java
14:53 - Array definition
34:47 - Cloning an array
40:17 - Program to count the number of occurrences of element x in a given array
44:25 - Dry run of code
47:05 - Program to find the last occurrence of element x in a given array
53:53 - Program to count the number of elements strictly greater than a value x
54:57 - Program to check if an array is sorted or not
1:05:13 - Bonus question
1:12:28 - Relevant information about static methods
1:14:00 - Summary of lecture

#Java #Introductiontomethodsinjava #Javamethods #PWskills #Physicswallah #coding #LearnCoding #Javaarrays #howtocode #ArraysinJava #2DArrays #Introductiontoarray #ArrayinJava #Programming #Java #Whatisanarray
Рекомендации по теме
Комментарии
Автор

47:09 this question can also be done by running the loop backward i.e., from arr.length-1 to 0. whenever the value of x is found it will print and break out of the loop

TheRankingSage
Автор

create different class for every types of questions instead of solving all the question in one program and also do share the source code so in case we have to look something into it we can directly refer the code instead of coming on youtube again for the source code .
Rest is everything good your teaching skill is owesome and also help full due this i am able to solve the hakerrank question now

ashishramsagaryadav
Автор

manvi mam dialogue "iska banta tha badlna par ye kaise badal gya".😃👏👏

sumittiwari
Автор

Ek code likhne ke baad jb doosra code likhte hai to new file bana le .It will be easy for us to understand🙏🙏🙏.Aur likhne ke baad pura code too aache se dikha digiye in one screen

shubham-...
Автор

Solution Bonus question : 1:12:24 👇

// Sorting of array using sort method
import java.util.Arrays;
import java.util.Scanner;

public class Aarrys {

static int[] kathIndex(int[] array, int k) {
Arrays.sort(array);
int ans[] = { array[(k - 1)], array[(array.length - 1 - k)] };
return ans;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
System.out.print("Enter k th value :");
int k = sc.nextInt();

System.out.println("Enter your array size ");
int n = sc.nextInt();

int[] array = new int[n];
System.out.println(" Enter your " + n + " size");

for (int i = 0; i < n; i++) {
arry[i] = sc.nextInt();

}
int[] ans = kathIndex(array, k);
System.out.println("\n " + k + "th Smallest element : " + ans[0]);
System.out.println(" " + k + "th Largest element : " + ans[1]);

}
}

trouble
Автор

Find kth smallest and largest elements is :
for smallest arr[k-1]
For largest arr[arr.length-k]

modanwalpriti
Автор

Aaj din me hi aa gaya lecture 😅 Badiya hai, thodi der me dekhunga

rajatgarg
Автор

mam hr concept alag file me krvaya kijiye aise bht confusion hota hai

vaibhavsharma
Автор

54:20
public class Main
{
public static void main(String[] args) {
int[] arr = {5, 6, 5, 3, 5, 4};
int x = 5;
int c = 0;
for (int i = arr.length-1;i>=0 ;i-- ) {
if (arr[i] > x) {
c++;
}
}
System.out.print(c);
}
}

harshchauhan
Автор

Amazing lecture.
Thanks a lot Manvi man and PW team.

Altamas
Автор

Answer is :
static void arr, int k){
Arrays.sort(arr);
for(int i=0; i<arr.length; i++){
System.out.print(arr[i]+", ");
}
System.out.println();
System.out.println(k+" th smallest element in array is "+arr[k-1]);
System.out.println(k+" th Largest element in array is "+arr[arr.length-k]);


}

codewithdh
Автор

Thank you ma'am, It is very helpful to many student

cs-rohitsahu
Автор

Ma'am dsa ke bahut saare playlist hai already, agar aapko is playlist to thoda unique banana hai to dsa ke har concept ke baad uske practice questions kriyega jaada.
Isse concepts clear honge ache se.

Timepassgaming
Автор

for kth smallest we will do arr[k-1] and kth largest arr[arr.length-k]

CRICTHAT
Автор

48:00
public class Main
{
public static void main(String[] args) {
int[] arr = {5, 6, 5, 3, 5, 4};
int x = 5;
for (int i = arr.length-1;i>=0 ;i-- ) {
if (arr[i] == x) {
System.out.print(i);
break;
}
}
}
}

we can also search from the end

harshchauhan
Автор

54:53
int[] arr = {1, 7, 9, 4, 5};
int X = 6;
int count = 0;

for (int i = 0; i < arr.length; i++) {
if (arr[i] > X) {
count++;
}
}

devvariya
Автор

Saare concept ek hi file me kr k lecture ka kachra kr diya

factzfacts
Автор

Bonus question
int [] arr= {1, 5, 6, 8, 3, 4, 1, 36};
Arrays.sort(arr);

int test=4;

int small = 0;
int big = 0;

for (int i=0;i<arr.length;i++){
if (test>arr[i]){
small++;
} else if (test<arr[i]) {
big++;
}
}
System.out.println(test+" is smaller than "+small+" numbers");
System.out.println(test+" is bigger than "+big+" numbers");

NiharikaB
Автор

Best was -8.00 "Yaar sorting t ho rha h bda mast" too good ur flow of dialogue 😅

karnt
Автор

Thank u mam for maintaining the consistency

syedmaaz
join shbcf.ru