1545. Find Kth Bit in Nth Binary String | Leetcode Daily Challenge | DSA | Java | FAANG

  Рет қаралды 2,638

shashCode

shashCode

Күн бұрын

Пікірлер: 13
@shashwat_tiwari_st
@shashwat_tiwari_st Ай бұрын
Like target is 150! Please do like if you have understood the explanation as well as the code!
@yashchandanshiv9172
@yashchandanshiv9172 Ай бұрын
great explanation
@Algo_algae
@Algo_algae Ай бұрын
Bhaiya i m regularly watching your videos and i love the way how you explain all the questions from scratch..But it not neccessary that every video must be like near 20 min if you take more time 30 min/40 min it will be okay for us becoz what we want is to understand the concept in depth so that we can also solve similar questions in fututre. So i request you that please also explain concept which used in queestion and how to recognize that pattern in depth. thanks again for your valuable efforts and for your time that you r giving to us from your busy schedule ❤❤❤❤
@Algo_algae
@Algo_algae Ай бұрын
you haven't discussed O(1) approach which is given in editorial section
@NishantPandat-l3q
@NishantPandat-l3q Ай бұрын
Nice explain sir
@opkrchauhan_1
@opkrchauhan_1 Ай бұрын
class Solution { public char findKthBit(int n, int k) { String str = getString(n); char ch=str.charAt(0); for(int i=0;i
@maniBrave
@maniBrave Ай бұрын
nice explanation
@rudrakshgupta1978
@rudrakshgupta1978 Ай бұрын
CPP Solution class Solution { public: char fn(int len,int k){ if(len==1){ return '0'; } int half=len/2; int middle=half+1; if(k==middle){ return '1'; }else if(k
@dr.coffin16
@dr.coffin16 Ай бұрын
Brute Force -CPP class Solution { public: string invert_and_reverse(const string& s){ string inverted; for(char ch : s){ inverted += (ch == '0') ? '1' : '0'; } reverse(inverted.begin(),inverted.end()); return inverted; } string generatebinary(int n){ if(n==1){ return "0"; } string s="0"; for(int i=2;i
@anuskakuila4177
@anuskakuila4177 Ай бұрын
is it working in leetcode
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Ай бұрын
public int find KthBit(int n,int k){ int cnt=0,len=(int)Math.pow(2,n)-1; while(k>1){ if(k==len/2+1){ return cnt%2==0?'1':'0'; } if(k>len/2){ k=len+1-k; cnt++; } len/=2; } return cnt%2==0?'0':'1'; } Iterater apporach 🎉❤
@shashwat_tiwari_st
@shashwat_tiwari_st Ай бұрын
@@dayashankarlakhotia4943 very nice 👌 👍 👏
@is_Debu
@is_Debu Ай бұрын
I came up with Brute Force++(Recursion❗) 🥲: class Solution { public char findKthBit(int n, int k) { String ans = helper(n); return ans.charAt(k-1); } String reverse(String str){ StringBuilder sb = new StringBuilder(str); sb.reverse(); return sb.toString(); } String replace0_1(String str){ StringBuilder sb = new StringBuilder(); for(char ch : str.toCharArray()){ sb.append((ch == '0' ? '1' : '0')); } return sb.toString(); } String helper(int n){ if(n == 1){ return "0"; } return helper(n-1) + "1" + reverse(replace0_1(helper(n-1))); } }
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 6 МЛН
Count Square Submatrices with All Ones - Leetcode 1277 - Python
22:01
Remove Sub-Folders from the Filesystem - Leetcode 1233 - Python
19:29
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 6 МЛН