Because at any instant only at max sqrt(n) element can be present within a queue because in bfs we go level by level. Do a dry run for better understanding,
Day-3 : My submission for today: Code in java: class Solution { public int[] findDiagonalOrder(List nums) { int maxSum=0; ArrayList ans=new ArrayList(); HashMap hmap= new HashMap(); for(int i= nums.size()-1;i>=0;i--){ for(int j=0;j
Do look at both the approaches and also an extra diagonal trick in this, can be asked as a follow up question ❤!
Consistency 100%
1
Line 3 is your comment is your answer 🙃
Amazing explanation, keep going 😊
bfs explanations is awsome.
I think we should use a map instead of an un ordered map in the first approach
great solution will you tell me how space complexity is O(sqrt(n)) ?
Because at any instant only at max sqrt(n) element can be present within a queue because in bfs we go level by level. Do a dry run for better understanding,
nice!!, thx
Day-3 :
My submission for today:
Code in java:
class Solution {
public int[] findDiagonalOrder(List nums) {
int maxSum=0;
ArrayList ans=new ArrayList();
HashMap hmap= new HashMap();
for(int i= nums.size()-1;i>=0;i--){
for(int j=0;j
Bhai sab theek hai ,punjabi nahi aati toh mat bola kar please
2nd one approach is super sexiii, aryan bro .
I have been able to do myself in nlong n time 🥲🥲