Java Hyd Team
746 subscribers
986 photos
39 videos
670 files
690 links
https://teamhydteam.my.canva.site/

Can visit us on our website 😊
Still working on it 😊
Download Telegram
Clicked n run less than a time click less than a fraction of second
Same question with 2 solutions with 0ms & 1 ms
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.complete it today by Eod
Example 1:

Input: s = "()"
Output: true
Example 2:

Input: s = "()[]{}"
Output: true
Example 3:

Input: s = "(]"
Output: false


Constraints:

1 <= s.length <= 104
s consists of parentheses only '()[]{}'.
3 possible solutions as per me
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:


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.
/**
* 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) {
ListNode head = new ListNode(0);

if(list1 == null && list2 == null) return null; //null checking
if(list1 == null) return list2;
if(list2 == null) return list1;

if(list1.val > list2.val) { //comparing and merging
head = list2;
list2 = list2.next;
}
else {
head = list1;
list1 = list1.next;
}

head.next = mergeTwoLists(list1, list2);
return head;
}
}
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
class Solution {
public List<List<String>> solveNQueens(int n) {

}
}
int a= 10;
int b = 20;
gpay G = (r,s)->{r*s};
G.amount(a,b);
gpay G : test::amountgpay;

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
}
}
πŸ‘1