String Compression | Amazon | Snapchat | Microsoft | Leetcode 443

preview_player
Показать описание
This is our 1st Video on our String Playlist
In this video we will try to solve a very interesting Problem : "String Compression".

Share your learnings on LinkedIn, Twitter (X), Instagram, Facebook(Meta) with the hashtag #codestorywithmik & feel free to tag me.

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

Problem Name : String Compression
Company Tags : Snapchat, GoDaddy, Lyft, Expedia, Microsoft, Bloomberg, Amazon, CouponDunia, FactSet, Goldman Sachs, VMWare, Zoho

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

#coding #helpajobseeker #easyrecipes
#interviewpreparation #interview_ds_algo #hinglish
Рекомендации по теме
Комментарии
Автор

i do not understand this language (hindi?) but the illustrations were enough for me to follow through!. thank you! (dhanyavad?)

PrinceAdom
Автор

This is so beautifully explained. Loved your way. Thank you so much for this!!

hameedmulani
Автор

Found your channel randomly and ur explanations are amazing!! I hope you reach great levels 👊🏻

sarfraznawaz
Автор

loved how calm and composed you were during the explanation

Gurshxns
Автор

finally!! i found the great explaination from great teacher. thank you sir. And this is my frist problem from your string playlist. hope i will cover the whole 39 problems from this playlist. thanks again sir😍😍🙏

yashpaunikar
Автор

Welcome back bhai!!! Below is the Java implementation:

class Solution {
public int compress(char[] chars) {
int n = chars.length;
int index = 0;
int i =0;

while(i < n) {
char curr_char = chars[i];
int count = 0;
while(i < n && chars[i] == curr_char) {
i++;
count++;
}
chars[index++] = curr_char;
if(count > 1) {
String count_str = String.valueOf(count);
for(char ch : count_str.toCharArray()) {
chars[index] = ch;
index++;
}
}
}
return index;
}
}

JJ-tpdd
Автор

This is so beautifully explained. Loved your way. Thank you so much for this.

wearevacationuncoverers
Автор

Crystal clear explanation bro. Thanks a lot

souravjoshi
Автор

samjhate aap bhut accha ho par is video me aur confusion ho gayi

vartikatiwari
Автор

Got curious after seeing your reel in Instragram someone thanking you for your amazing explanation. You are doing Great Job, so beautifully, crystal clear explanation. Thank you, ❤

bashashaik
Автор

def compress(self, chars: List[str]) -> int:
temp=chars[0]
count=1
ans=[]
start=0
for i in range(1, len(chars)):
if temp==chars[i]:
count+=1
elif temp!=chars[i]:
ans.append(temp+str(count))
chars[start]=temp
start+=1
if count>1:
t=str(count)
for k in range(len(t)):
chars[start]=t[k]
start+=1
count=1
temp=chars[i]
chars[start]=temp
start+=1
if count>1:
t=str(count)
for k in range(len(t)):
chars[start]=t[k]
start+=1
return start


Done✅

jagadeeshp
Автор

do you think the code can be optimized by using ordered map and then just storing it in the array?

bliss_anand
Автор

I am trying this one of my own first, then I will post my solution then I will see your solution

pritishpattnaik
Автор

Hello bhaiya!!
bhaiya, yeh question me thodi dikkit a rhi string conversion me toh isko bta dijiyega .

3280. Convert Date to Binary

knight-zx
Автор

How to write the c and python program by using this approach?
Actually I am facing some difficulties

DebikaChatterjee-bb
Автор

we are using nested while loops so the time complexity is O(n^2) right ?

harsh.jain
Автор

please came up with " Remove Outermost Parentheses" solution

sayantanpoddar
Автор

got to know you from instagram
amazing explaination
keep stepping up your marketing game !!

somyaagarwal
Автор

Problem explanation was fabulous but too much while loop to solve this problem that is not optimize I think

letsexplore
Автор

What is the space complexity of this code?

sruthimajhi
visit shbcf.ru