Advertisement
jw910731

Untitled

Oct 19th, 2023
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     bool util(int i, int k) {
  4.         if(i == 1) return false;
  5.         if(k < (1<<(i-1))) return util(i-1, k);
  6.         if( k == (1<<(i-1)) ) return true;
  7.         return !util(i-1, (1<<i) - k);
  8.     }
  9.     char findKthBit(int i, int k) {
  10.         return util(i, k) ? '1' : '0';
  11.     }
  12. };
Tags: leetcode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement