Skip to content

Commit

Permalink
added solution of potd 19 october 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahendra2611 committed Oct 21, 2024
1 parent df97977 commit 35ea31c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions october_2024/potd_19_10_2024.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<bits/stdc++.h>
using namespace std;

void solve( string &s,int n){

while(n--){
s += "1";
for(int i = s.size()-2;i>=0;i--){
int id = s[i]-'0';
id = 1-id;
s.append(1,id+'0');
}
}
}

char findKthBit(int n, int k) {
string s = "0";
solve(s,n);
return s[k-1];
}
int main(){
int n,k;
cin>>n>>k;
char x = findKthBit(n,k);
cout<<x<<endl;
return 0;
}

0 comments on commit 35ea31c

Please sign in to comment.