LeetCode 1356: Sort by Number of 1 Bits ๐Ÿงฎ

Learn to solve LeetCode 1356, sorting integers based on the count of 1 bits, with a clear Java explanation. Easy level!

LeetCode 1356: Sort by Number of 1 Bits ๐Ÿงฎ
leetcoder_pooja
0 views โ€ข Feb 25, 2026
LeetCode 1356: Sort by Number of 1 Bits ๐Ÿงฎ

About this video

๐Ÿš€ **LeetCode 1356 | Sort Integers by The Number of 1 Bits | Easy | Java Explanation**

In this video, we solve **LeetCode Problem 1356 โ€“ Sort Integers by The Number of 1 Bits** using Java and understand the logic step-by-step.

๐Ÿ” **Problem Idea:**
We are given an array of integers. We must sort the numbers:
1๏ธโƒฃ Based on the **number of 1s (set bits)** in their binary representation.
2๏ธโƒฃ If two numbers have the same number of 1s, sort them in **ascending numerical order**.

๐Ÿ’ก This problem helps you understand:

* Binary representation of numbers
* Counting set bits using `Integer.bitCount()`
* Custom sorting with **Lambda Comparator** in Java
* How to sort based on multiple conditions (important for interviews!)

๐Ÿง  **Concepts Covered:**
โœ” Bit Manipulation Basics
โœ” Custom Sorting in Java
โœ” Comparator & Lambda Functions
โœ” Time Complexity Analysis
โœ” Dry Run Example Explanation

๐Ÿ“Œ **Example:**
Input: `[0,1,2,3,4,5,6,7,8]`
Output: `[0,1,2,4,8,3,5,6,7]`

---

โฑ **Timestamps:**
00:00 โ€“ Problem Explanation
01:20 โ€“ Understanding Binary & Set Bits
03:10 โ€“ Approach & Logic
05:00 โ€“ Java Code Walkthrough
08:00 โ€“ Dry Run Example
10:15 โ€“ Complexity Analysis
11:00 โ€“ Interview Tips

---

๐Ÿ”ฅ Practice this problem here:
LeetCode #1356 โ€“ Sort Integers by The Number of 1 Bits

---

๐Ÿ“š Follow for more Data Structures & Algorithms explanations, coding interview prep, and daily LeetCode solutions!

#LeetCode #DSA #JavaProgramming #BitManipulation #CodingInterview #GeekStreak #ProblemSolving #LearnToCode #WomenInTech #CSE

Video Information

Views

0

Duration

3:17

Published

Feb 25, 2026

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.