Java Hyd Team
You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1:…
Marked as easy 😂 but it's headache question
The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.
Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space, respectively.
Example 1:
Input: n = 4
Output: [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
Explanation: There exist two distinct solutions to the 4-queens puzzle as shown above
Example 2:
Input: n = 1
Output: [["Q"]]
Constraints:
1 <= n <= 9
Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.
Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space, respectively.
Example 1:
Input: n = 4
Output: [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
Explanation: There exist two distinct solutions to the 4-queens puzzle as shown above
Example 2:
Input: n = 1
Output: [["Q"]]
Constraints:
1 <= n <= 9
gpay G : test::amountgpay;
test t = new test();
PhonePay P : t::amountPhonepay
test t = new test();
PhonePay P : t::amountPhonepay
liste.stream().filter(a->a.basicSal > 45000).collect(Collectors.toList()).forEach(System.out::println);
Introduced in Java 8, the Stream API is used to process collections of objects. A stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result. A stream is not a data structure instead it takes input from the Collections, Arrays or I/O channels.
❤1
public class test {
public void Wa() {
System.out.println("i am from common bank");
}
public static void amount(int x, int y) {
System.out.println("Sender is "+ x +" and receiver is " +y);
}
public static void main(String... args) {
Withdraws a = new Withdraws() {
//Anonymous methods/ class we can use everywhere
@Override
public void withdrawAmount() {
// TODO Auto-generated method stub
System.out.println("i am from axisbank u can withdraw 40000.");
}};
//Lambda expression only for functional interfaces (SAM:- single abstract methods)
Withdraws h = ()-> {System.out.println("i am from hdfcBank u can withdraw 20,000");};//new hdfcBank();
Withdraws i = new iciciBank();//normal way
test t = new test();
Withdraws c = t::Wa;// method reference with instance method
int aa = 100;
// phonePay p = (v)->{System.out.println("Account bal is " + (v*100));};
// p.amount(aa);
// gpay g = (x, y) -> {System.out.println("Sender is "+ x +" and receiver is " +y);};
// g.amount(420, 440);
gpay g = test::amount;
g.amount(420, 440);
c.withdrawAmount();
a.withdrawAmount();
i.withdrawAmount();
h.withdrawAmount();
//default methods :- if we are implementing n number of
}
}
public void Wa() {
System.out.println("i am from common bank");
}
public static void amount(int x, int y) {
System.out.println("Sender is "+ x +" and receiver is " +y);
}
public static void main(String... args) {
Withdraws a = new Withdraws() {
//Anonymous methods/ class we can use everywhere
@Override
public void withdrawAmount() {
// TODO Auto-generated method stub
System.out.println("i am from axisbank u can withdraw 40000.");
}};
//Lambda expression only for functional interfaces (SAM:- single abstract methods)
Withdraws h = ()-> {System.out.println("i am from hdfcBank u can withdraw 20,000");};//new hdfcBank();
Withdraws i = new iciciBank();//normal way
test t = new test();
Withdraws c = t::Wa;// method reference with instance method
int aa = 100;
// phonePay p = (v)->{System.out.println("Account bal is " + (v*100));};
// p.amount(aa);
// gpay g = (x, y) -> {System.out.println("Sender is "+ x +" and receiver is " +y);};
// g.amount(420, 440);
gpay g = test::amount;
g.amount(420, 440);
c.withdrawAmount();
a.withdrawAmount();
i.withdrawAmount();
h.withdrawAmount();
//default methods :- if we are implementing n number of
}
}
👍1
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.*;
public class EdM1 extends EdM{
//private static final Object e = null;
public EdM1(int empNo, String empName, String gender, int basicSal, String city, String deptName) {
super(empNo, empName, gender, basicSal, city, deptName);
}
@SuppressWarnings("unchecked")
public static void main(String[] args) {
List <EdM1> liste= new ArrayList<EdM1>();
liste.add(new EdM1(1001,"Kannababu","m",40000,"Hyderabad","EIE"));
liste.add(new EdM1(1002,"Srinivas","m",42000,"Chennai","CSE"));
liste.add(new EdM1(1003,"Yakub","m",45000,"Banglore","CSE"));
liste.add(new EdM1(1004,"Venktesh","m",55000,"Hyderabad","CSE"));
liste.add(new EdM1(1005,"Samantha","f",65000,"Chennai","ECE"));
liste.add(new EdM1(1006,"Anushka","f",43000,"Banglore","EIE"));
liste.add(new EdM1(1007,"Shekhar","m",23000,"Banglore","EIE"));
//Q1.)
float sum=0;
float da;
float hra;float tsal;
for(EdM1 e:list) {
// System.out.println(e.empNo+","+e.empName+","+e.gender+","+e.basicSal+","+e.city+","+e.deptName);
System.out.println(e.toString());
// //Q2.)
// if(e.basicSal>45000)
// System.out.println(e.toString());
// //Q3.)
// if (e.city.equalsIgnoreCase("Hyderabad"))
// System.out.println(e.toString());
// //Q4.)
// System.out.println(list.size());
// //Q5.)
// if(e.deptName.equalsIgnoreCase("CSE"))
// System.out.println(e.toString());
// //Q6.)
// if(e.basicSal>45000 && e.basicSal<60000)
// System.out.println(e.toString());
// //Q7.)
// if(e.gender.equalsIgnoreCase("m") || e.gender.equalsIgnoreCase("f"))
// System.out.println(e.toString());
// //Q8.)
// if (e.city.equalsIgnoreCase("Hyderabad")&& e.basicSal>40000)
// System.out.println(e.toString());
// //Q9.)
// if (e.city.equalsIgnoreCase("Banglore"))
// for(int i = 0;i<list.size();i++)
// sum+= list.get(i);
//
// System.out.println(sum);
// sum = sum+ e.basicSal;
// }
// System.out.println(sum);
// System.out.println(e.toString());
// //Q10.)
// if(e.deptName.equalsIgnoreCase("ECE"))
// System.out.println(e.toString());
// //Q11.)
// da=(float) (0.20+basicSal);
// hra=(float) (0.40+basicSal);
// tsal = da + hra + basicSal;
// System.out.println(e.toString()+tsal);
//Q12.)
// if(e.empName.equalsIgnoreCase("Samantha"))
// System.out.println(e.basicSal);
// }
// Comparator com = (Object o1, Object o2)-> {
// EdM e1 = (EdM)o1;
// EdM e2 = (EdM)o2;
// return e2.empName.compareTo(e1.empName);
// };
// Collections.sort(liste, com);
// for(EdM1 a : liste) {
// System.out.println(a.toString());
// }
//Consumer c = (e) -> {System.out.println(e);};
// Consumer c = System.out::println;
// liste.forEach(c);
// Stream s = liste.stream().filter(e-> e.basicSal > 45000);
// s.forEach(System.out::println);
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.*;
public class EdM1 extends EdM{
//private static final Object e = null;
public EdM1(int empNo, String empName, String gender, int basicSal, String city, String deptName) {
super(empNo, empName, gender, basicSal, city, deptName);
}
@SuppressWarnings("unchecked")
public static void main(String[] args) {
List <EdM1> liste= new ArrayList<EdM1>();
liste.add(new EdM1(1001,"Kannababu","m",40000,"Hyderabad","EIE"));
liste.add(new EdM1(1002,"Srinivas","m",42000,"Chennai","CSE"));
liste.add(new EdM1(1003,"Yakub","m",45000,"Banglore","CSE"));
liste.add(new EdM1(1004,"Venktesh","m",55000,"Hyderabad","CSE"));
liste.add(new EdM1(1005,"Samantha","f",65000,"Chennai","ECE"));
liste.add(new EdM1(1006,"Anushka","f",43000,"Banglore","EIE"));
liste.add(new EdM1(1007,"Shekhar","m",23000,"Banglore","EIE"));
//Q1.)
float sum=0;
float da;
float hra;float tsal;
for(EdM1 e:list) {
// System.out.println(e.empNo+","+e.empName+","+e.gender+","+e.basicSal+","+e.city+","+e.deptName);
System.out.println(e.toString());
// //Q2.)
// if(e.basicSal>45000)
// System.out.println(e.toString());
// //Q3.)
// if (e.city.equalsIgnoreCase("Hyderabad"))
// System.out.println(e.toString());
// //Q4.)
// System.out.println(list.size());
// //Q5.)
// if(e.deptName.equalsIgnoreCase("CSE"))
// System.out.println(e.toString());
// //Q6.)
// if(e.basicSal>45000 && e.basicSal<60000)
// System.out.println(e.toString());
// //Q7.)
// if(e.gender.equalsIgnoreCase("m") || e.gender.equalsIgnoreCase("f"))
// System.out.println(e.toString());
// //Q8.)
// if (e.city.equalsIgnoreCase("Hyderabad")&& e.basicSal>40000)
// System.out.println(e.toString());
// //Q9.)
// if (e.city.equalsIgnoreCase("Banglore"))
// for(int i = 0;i<list.size();i++)
// sum+= list.get(i);
//
// System.out.println(sum);
// sum = sum+ e.basicSal;
// }
// System.out.println(sum);
// System.out.println(e.toString());
// //Q10.)
// if(e.deptName.equalsIgnoreCase("ECE"))
// System.out.println(e.toString());
// //Q11.)
// da=(float) (0.20+basicSal);
// hra=(float) (0.40+basicSal);
// tsal = da + hra + basicSal;
// System.out.println(e.toString()+tsal);
//Q12.)
// if(e.empName.equalsIgnoreCase("Samantha"))
// System.out.println(e.basicSal);
// }
// Comparator com = (Object o1, Object o2)-> {
// EdM e1 = (EdM)o1;
// EdM e2 = (EdM)o2;
// return e2.empName.compareTo(e1.empName);
// };
// Collections.sort(liste, com);
// for(EdM1 a : liste) {
// System.out.println(a.toString());
// }
//Consumer c = (e) -> {System.out.println(e);};
// Consumer c = System.out::println;
// liste.forEach(c);
// Stream s = liste.stream().filter(e-> e.basicSal > 45000);
// s.forEach(System.out::println);
👍1
Top Java Interview Questions and Answers (2022) - InterviewBit
https://www.interviewbit.com/java-interview-questions/amp/
https://www.interviewbit.com/java-interview-questions/amp/
When I started learning 𝗗𝗦𝗔. I didnt know how difficult it was going to be or for how long I will be able to give time to this. I only knew basics of C++ and some basic data structure like: stacks and queues.
And still, DSA and System Design are the two things upon which you'll be most grilled on in interviews of almost all product-based companies.
But bhaiya, mai try toh kar rha hu, par questions hote hi nhi hai.
Kya karu, I'm getting demotivated.😐
I remember, I also feel the same way when I started with DSA in my college.
I heard about 𝗦𝗣𝗢𝗝, 𝗰𝗼𝗱𝗲𝗰𝗵𝗲𝗳 and 𝗵𝗮𝗰𝗸𝗲𝗿𝗿𝗮𝗻𝗸 in college. I tried 𝗖𝗼𝗱𝗲𝗖𝗵𝗲𝗳, could not understand the UI and how to read the inputs in my program, so I left it. Looked at 𝗦𝗣𝗢𝗝, didnt like the UI either.
I tried 𝗚𝗲𝗲𝗸𝘀𝗳𝗼𝗿𝗴𝗲𝗲𝗸, then jumped to 𝗖𝗼𝗱𝗲𝗖𝗵𝗲𝗳, 𝗛𝗮𝗰𝗸𝗲𝗿𝗘𝗮𝗿𝘁𝗵, 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲, etc, and in fact participated in a lot of contests.⭐
It's not really hard to master DSA. It's just you need to be more consistent in solving at least a problem daily.
Believe me, Consistency is the Key ⏳
Some of the Major reasons people not improving in problem-solving and DSA is they are lacking consistency.
Hard to do LeetCode or GeeksForGeeks daily, but if you convince your mind to do it as a habit then it will be easy.
No matter what happens, you will 𝗳𝗲𝗲𝗱 𝗼𝘂𝗿𝘀𝗲𝗹𝘃𝗲𝘀 daily because you have been doing it for a long time and you have no trouble doing it.
Try to do same habit with your favourite coding platform..
Fix a slot in the day / night as per your convenience, and do LeetCode daily at the same time.
Doing this 2-3 months without missing a single day, missing a day will be more difficult in doing LeetCode that day.
You'll soon see the magic of being consistent in your problem-solving skills.
Freshly, I came across this useful resource of DSA. You can have a look at it by clicking on the given link below.
And still, DSA and System Design are the two things upon which you'll be most grilled on in interviews of almost all product-based companies.
But bhaiya, mai try toh kar rha hu, par questions hote hi nhi hai.
Kya karu, I'm getting demotivated.😐
I remember, I also feel the same way when I started with DSA in my college.
I heard about 𝗦𝗣𝗢𝗝, 𝗰𝗼𝗱𝗲𝗰𝗵𝗲𝗳 and 𝗵𝗮𝗰𝗸𝗲𝗿𝗿𝗮𝗻𝗸 in college. I tried 𝗖𝗼𝗱𝗲𝗖𝗵𝗲𝗳, could not understand the UI and how to read the inputs in my program, so I left it. Looked at 𝗦𝗣𝗢𝗝, didnt like the UI either.
I tried 𝗚𝗲𝗲𝗸𝘀𝗳𝗼𝗿𝗴𝗲𝗲𝗸, then jumped to 𝗖𝗼𝗱𝗲𝗖𝗵𝗲𝗳, 𝗛𝗮𝗰𝗸𝗲𝗿𝗘𝗮𝗿𝘁𝗵, 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲, etc, and in fact participated in a lot of contests.⭐
It's not really hard to master DSA. It's just you need to be more consistent in solving at least a problem daily.
Believe me, Consistency is the Key ⏳
Some of the Major reasons people not improving in problem-solving and DSA is they are lacking consistency.
Hard to do LeetCode or GeeksForGeeks daily, but if you convince your mind to do it as a habit then it will be easy.
No matter what happens, you will 𝗳𝗲𝗲𝗱 𝗼𝘂𝗿𝘀𝗲𝗹𝘃𝗲𝘀 daily because you have been doing it for a long time and you have no trouble doing it.
Try to do same habit with your favourite coding platform..
Fix a slot in the day / night as per your convenience, and do LeetCode daily at the same time.
Doing this 2-3 months without missing a single day, missing a day will be more difficult in doing LeetCode that day.
You'll soon see the magic of being consistent in your problem-solving skills.
Freshly, I came across this useful resource of DSA. You can have a look at it by clicking on the given link below.