Topfolio
Career TracksFree CoursesPracticeWork ExperienceProjects
For Employers
Start Free
Topfolio

Learn data analytics online. Real skills, real projects, real community.

courses

  • Career Tracks
  • Work Experience
  • Best Data Analyst Course in India
  • SQL Fundamentals
  • SQL Advanced
  • Python for Data
  • Micro Free Courses

practice

  • SQL Fundamentals Interview Test
  • SQL Advanced Coding Test
  • All Practice Tests

resources

  • How to Become a Data Analyst
  • SQL Interview Questions
  • Data Analyst Salary Guide
  • Free Datasets for Practice
  • SQL vs NoSQL Guide
  • Data Analyst vs Data Engineer vs Data Scientist

employers

  • Enterprise Screening
  • AI Proctoring Demo
  • Volume Pricing
  • Employer Portal

company

  • About
  • Terms
© 2026 Topfolio. All rights reserved.Made with ❤️ for aspiring analysts
Topfolio
Career TracksFree CoursesPracticeWork ExperienceProjects
For Employers
Start Free

Single Number + Counting Bits

easy~10 min15 pts
📊 View Insights

Problem

# Single Number + Counting Bits Two bit tricks from Module 2's Bit Manipulation lesson, back to back — currently zero mock coverage of this topic despite a full taught unit. 1. **Single Number:** given a list where every element appears twice except one, return that one element in O(N) time, O(1) space (XOR-cancellation: `a ^ a == 0`, `a ^ 0 == a`). 2. **Counting Bits:** given `n`, return a list `counts` where `counts[i]` is the number of 1-bits in `i`, for every `i` from `0` to `n` (Brian Kernighan-style DP-on-bits: `counts[i] = counts[i >> 1] + (i & 1)`). Return both as a dict: `{'single_number': ..., 'counting_bits': [...]}`. **Example:** `nums=[4,1,2,1,2], n=3` -> `{'single_number': 4, 'counting_bits': [0,1,1,2]}`.
dsabit-manipulation
📊
📊 View Question Telemetry & Insights
Failure rate, silent bug autopsy & optimal query construction
Inspect →

Master SQL & Data Analytics

Ready to take your skills to the next level? Enroll in our comprehensive Data Analyst Career Track to master SQL, Python, Excel, and Power BI.

Explore the 12-Week Data Analyst Career Track

Related questions

  • Longest Substring with At Most K Distinct Charactersmedium
  • Subarray Sum Equals Kmedium
  • Daily Temperatureseasy
  • Generate All Subsetsmedium
  • Binary Tree Level Order Traversalmedium
  • K Closest Points to Originmedium
  • Number of Provincesmedium
  • Cheapest Flights Within K Stopshard
SQL Editor

Run your code to see the result here.

Topfolio

Learn data analytics online. Real skills, real projects, real community.

courses

  • Career Tracks
  • Work Experience
  • Best Data Analyst Course in India
  • SQL Fundamentals
  • SQL Advanced
  • Python for Data
  • Micro Free Courses

practice

  • SQL Fundamentals Interview Test
  • SQL Advanced Coding Test
  • All Practice Tests

resources

  • How to Become a Data Analyst
  • SQL Interview Questions
  • Data Analyst Salary Guide
  • Free Datasets for Practice
  • SQL vs NoSQL Guide
  • Data Analyst vs Data Engineer vs Data Scientist

employers

  • Enterprise Screening
  • AI Proctoring Demo
  • Volume Pricing
  • Employer Portal

company

  • About
  • Terms
© 2026 Topfolio. All rights reserved.Made with ❤️ for aspiring analysts