Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise.
An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.
An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.
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.
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.
Input: list1 = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]
Example 2:
Input: list1 = [], list2 = []
Output: []
Example 3:
Input: list1 = [], list2 = [0]
Output: [0]
Constraints:
The number of nodes in both lists is in the range [0, 50].
-100 <= Node.val <= 100
Both list1 and list2 are sorted in non-decreasing order.
Output: [1,1,2,3,4,4]
Example 2:
Input: list1 = [], list2 = []
Output: []
Example 3:
Input: list1 = [], list2 = [0]
Output: [0]
Constraints:
The number of nodes in both lists is in the range [0, 50].
-100 <= Node.val <= 100
Both list1 and list2 are sorted in non-decreasing order.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
}
}
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
}
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
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());
// }
liste.forEach(System.out::println);
//liste.stream().filter(a->a.basicSal > 45000).collect(Collectors.toList()).forEach(System.out::println);
}
}
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
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());
// }
liste.forEach(System.out::println);
//liste.stream().filter(a->a.basicSal > 45000).collect(Collectors.toList()).forEach(System.out::println);
}
}
import java.util.*;
public class EdM implements Comparable {
int empNo;
String empName;
String gender;
int basicSal;
String city;
String deptName;
public EdM(int empNo,String empName,String gender,int basicSal,String city,String deptName) {
this.empNo=empNo;
this.empName=empName;
this.gender=gender;
this.basicSal=basicSal;
this.city=city;
this.deptName=deptName;
}
@Override
public String toString() {
return "Employee [empno=" + empNo + ", empname=" + empName + ", gender=" + gender + ", bsal=" + basicSal + ", city="
+ city + ", deptname=" + deptName + "]";
}
// public float compareTo(EdM o) {
// if(this.basicSal == o.basicSal) {
// return 0;
// } else if (this.basicSal < o.basicSal) {
// return 1;
// }else {
// return -1;
// }
// }
@Override
public int compareTo(Object o) {
EdM e = (EdM)o;
// if(this.basicSal == e.basicSal) {
// return 0;
// }
// else if (this.basicSal<e.basicSal) {
// return 1;
// } else {
// return -1;
//
return e.basicSal - this.basicSal;
}
}
public class EdM implements Comparable {
int empNo;
String empName;
String gender;
int basicSal;
String city;
String deptName;
public EdM(int empNo,String empName,String gender,int basicSal,String city,String deptName) {
this.empNo=empNo;
this.empName=empName;
this.gender=gender;
this.basicSal=basicSal;
this.city=city;
this.deptName=deptName;
}
@Override
public String toString() {
return "Employee [empno=" + empNo + ", empname=" + empName + ", gender=" + gender + ", bsal=" + basicSal + ", city="
+ city + ", deptname=" + deptName + "]";
}
// public float compareTo(EdM o) {
// if(this.basicSal == o.basicSal) {
// return 0;
// } else if (this.basicSal < o.basicSal) {
// return 1;
// }else {
// return -1;
// }
// }
@Override
public int compareTo(Object o) {
EdM e = (EdM)o;
// if(this.basicSal == e.basicSal) {
// return 0;
// }
// else if (this.basicSal<e.basicSal) {
// return 1;
// } else {
// return -1;
//
return e.basicSal - this.basicSal;
}
}