This is a verified interview question from Nvidia. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Validate Binary String as Power of 2" covers key patterns like Other.
"### Problem - This need to be solved in C language only Given a binary string(contains only 0 or 1), find a regex(regural expression) that checks whether that binary number when converted to a decimal number is a power of two or not. Complete the code in the editor below by replacing the blank (i.e., "____") with a regular expression that matches something according to the criterion above. Locked code in the editor prints True for each correct match and False for each incorrect match. ### Example s = '0101010' This is 42 decimal which is not a power of 2. The regex should return a false value and the code stub will print 'False'. ### Constraints - Test strings consist only of ascii characters '0' or '1'"
Join thousands of developers practicing for Nvidia.