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!

leetcoder_pooja
0 views โข Feb 25, 2026

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
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 TRENDSRelated trending topics. Click any trend to explore more videos.