Summary Ranges | Leetcode-228 | GOOGLE | Explanation ➕ Live Coding

preview_player
Показать описание
Hi everyone, this is the 47th video of our Array Playlist.
In this video we will try to solve a very easy but good Array Qn “Summary Ranges”.
It has been asked by Google. Since it's easy, it really matters how clean your code is.

We will write very easy and clean code.
We will do live coding after explanation and see if we are able to pass all the test cases.

Problem Name : Summary Ranges
Company Tags : GOOGLE

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Рекомендации по теме
Комментарии
Автор

Your videos are always so informative and well-presented. Thank you for sharing your knowledge with us!🚀😎

MyCodingDiary
Автор

Thank you so much for giving insights on each problem.

wearevacationuncoverers
Автор

Your explanations are best bro❤🎉🎉..keep making videos and helping others👍

HarshKumar-lifg
Автор

Thanks helpful ❤ was getting runtime error but now it's clear 🎉

OnlyUpscOrBpsc
Автор

bhaiya please make a video on 2736. Maximum Sum Queries asked yesterday on lc weekly . bina segment tree ke . Please

thedarkknight
Автор

Bro, you are doing a great job. Thanks for all the efforts :)

theayushr
Автор

for ke andar while loop bhi hai na toh o(n^2) nahi hoga tc?

tusharkumarraj
Автор

brother i was able to recognise that i need the start end number of for loops and pointers i need but the code never run even in case of easy one . how to build logic more precisely tell me.

devanshu
Автор

Can you make solutions for weekly and biweekly contest problems please?I have a problem with a question(2736) from the contest and cannot understand the written solution, also i cant find videos on the problem.

siddharthtiwari
Автор

Amazing. Our placements are coming and these videos are really helpful. I have a question, can you make a playlist covering every topic(only the quick explanation not the code or anything important) important in few videos? I understand and respect your time, so its okay if you cant.😁

danishsinghjamwal
Автор

Early in the morning 👀, isn't it falls in sliding window? Where the size of a window is smallest range possible?

aaravmishra
Автор

Bhaiya isko javascript ke sath implement karna h kaise kru

thephalcon
Автор

sir leetcode's site is down, how will I solve the potd now? My streak will break😭

riyakansal
Автор

Ive a doubt, are topics like fenwick trees, segment trees etc. Important for freshers interview or internship in college? Btw amazing video as always

atmanirbharofficialindiaon
Автор

overflow wala samjh nai aya...ek example se explain kr skte ho kya?

tarunstv
Автор

this is again O(n2), I have developed a code with O(n), check it out :
public List<String> summaryRanges(int[] nums) {
List l = new ArrayList<String>();


int i =0, j= 0;

while(i < nums.length || j<nums.length) {

if(j<nums.length-1 && nums[j+1]==nums[j]+1) {
j++;
}
else {
if(i<j)
l.add(nums[i] +"->" + nums[j]);

else
l.add(nums[i] +"");

j++;

i = j ;
}

}

return l ;
}

sauravclark
Автор

Java Implementation:
class Solution {
public List<String> summaryRanges(int[] nums) {
int n = nums.length;
List<String> res = new ArrayList<>();
for(int i=0; i<n; i++) {
int start = nums[i];
while(i+1<n && nums[i] + 1 == nums[i+1]) {
i++;
}
if(start != nums[i]) {

}
else {

}
}
return res;
}
}

JJ-tpdd
Автор

can you please take the question from leetcode - find median of two sorted arrays its a hard question. heres my code which is giving ru[ntime error:
#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
double a, vector<int>& b) {
int n = a.size(), m = b.size();
if (n < m){
findMedianSortedArrays(b, a);
}
int lo = 0, hi = n;
int te = n + m;

while (lo <= hi){
int aleft = (lo + hi)/2;
int bleft = (te + 1)/2 - aleft;

int alm1 = (aleft == 0) ? INT_MIN : a[aleft - 1];
int al = (aleft == n) ? INT_MAX : a[aleft];
int blm1 = (bleft == 0) ? INT_MIN : b[bleft - 1];
int bl = (bleft == m) ? INT_MAX : b[bleft];

//valid segregation
if (alm1 <= bl && blm1 <= al){
double median = 0.0;
if (te % 2 == 0){
int lMax = max(alm1, blm1);
int rMin = min(al, bl);
median = (lMax + rMin)/2.0;
}
else{
int lMax = max(alm1, blm1);
median = lMax;
}
return median;
}
else if (alm1 > bl){
//there are more elements to be picked in left part of 'b' array
hi = aleft - 1;
}
else if (blm1 > al){
//there are more elements to be picked in left part of 'a' array
lo = aleft + 1;
}
}
return 0;

}
};

shadabkalim
welcome to shbcf.ru