{"id":"f5dd29d2-b3d9-465d-a9b0-ef9b499a352f","name":"Nth Palindromic Binary","description":"1. You are given an integer N.\r\n2. You have to find the N-th number whose binary representation is a palindrome.\r\n\r\nNote -> First binary number whose representation is a palindrome is 1.","inputFormat":"A number N","outputFormat":"Check the sample output and question video.","constraints":"1 &lt;= n &lt;= 2*10^4","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n\n\nint NthPalindromicBinary(int n)\n{\n \n}\n\nint main()\n{\n int n;cin>>n;\n int ans=NthPalindromicBinary(n);\n cout<<ans<<\"\\n\";\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int NthPalindromicBinary(int n) {\r\n //write your code here\r\n \r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n System.out.println(NthPalindromicBinary(n));\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"17","sampleOutput":"85\r\n","questionVideo":"https://www.youtube.com/embed/QYoWR8hDCyQ?end=893","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f3e3dbef-d2b7-4f6d-b357-2ef3738e6c91","name":"Bit Manipulation For Intermediate","slug":"bit-manipulation-for-intermediate-9995","type":0},{"id":"26393e3d-1481-4c59-9d79-e08d2d8b628c","name":"Nth Palindromic Binary","slug":"nth-palindromic-binary","type":1}],"next":{"id":"c13f0595-cd52-4d3d-9e46-027fc63bbde2","name":"Nth PALINDROMIC BINARY","type":3,"slug":"nth-palindromic-binary"},"prev":{"id":"a3ce191c-9c68-48b4-91b0-cc5b694b95d2","name":"MIN XOR PAIRS","type":3,"slug":"min-xor-pairs"}}}

Nth Palindromic Binary

1. You are given an integer N. 2. You have to find the N-th number whose binary representation is a palindrome. Note -> First binary number whose representation is a palindrome is 1.

{"id":"f5dd29d2-b3d9-465d-a9b0-ef9b499a352f","name":"Nth Palindromic Binary","description":"1. You are given an integer N.\r\n2. You have to find the N-th number whose binary representation is a palindrome.\r\n\r\nNote -> First binary number whose representation is a palindrome is 1.","inputFormat":"A number N","outputFormat":"Check the sample output and question video.","constraints":"1 &lt;= n &lt;= 2*10^4","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n\n\nint NthPalindromicBinary(int n)\n{\n \n}\n\nint main()\n{\n int n;cin>>n;\n int ans=NthPalindromicBinary(n);\n cout<<ans<<\"\\n\";\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int NthPalindromicBinary(int n) {\r\n //write your code here\r\n \r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n System.out.println(NthPalindromicBinary(n));\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"17","sampleOutput":"85\r\n","questionVideo":"https://www.youtube.com/embed/QYoWR8hDCyQ?end=893","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f3e3dbef-d2b7-4f6d-b357-2ef3738e6c91","name":"Bit Manipulation For Intermediate","slug":"bit-manipulation-for-intermediate-9995","type":0},{"id":"26393e3d-1481-4c59-9d79-e08d2d8b628c","name":"Nth Palindromic Binary","slug":"nth-palindromic-binary","type":1}],"next":{"id":"c13f0595-cd52-4d3d-9e46-027fc63bbde2","name":"Nth PALINDROMIC BINARY","type":3,"slug":"nth-palindromic-binary"},"prev":{"id":"a3ce191c-9c68-48b4-91b0-cc5b694b95d2","name":"MIN XOR PAIRS","type":3,"slug":"min-xor-pairs"}}}
plane

Editor


Loading...

Nth Palindromic Binary

easy

1. You are given an integer N. 2. You have to find the N-th number whose binary representation is a palindrome. Note -> First binary number whose representation is a palindrome is 1.

Constraints

1 <= n <= 2*10^4

Format

Input

A number N

Output

Check the sample output and question video.

Example

Sample Input

17

Sample Output

85

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode