Lua Coding Practice

Solve Binary Array Sorting using Lua Language

Solve Binary Array Sorting using Lua to enhance your skills with lua coding practice , master coding concepts, and prepare for interviews with practical exercises and detailed solutions.

Binary Array Sorting

Difficulty : Easy

Categories :

  • Arrays
  • Sorting algorithms

Given a binary array (array containing only 0s and 1s), rearrange it in increasing order in-place. The array should be modified directly without using any extra space.

Constraints:

  • 1 ≤ arr.length ≤ 106
  • arr[i] ∈ {0,1} for all i
  • Must modify array in-place
  • No extra space allowed

Examples:

Input: arr = [1,0,1,1,0]
Output: [0,0,1,1,1]
Explanation: All zeros are moved to the front, followed by ones
Input: arr = [1,0,1,1,1,1,1,0,0,0]
Output: [0,0,0,0,1,1,1,1,1,1]
Explanation: Four zeros followed by six ones

Problem Solving

Input

What You'll Find Here

Real-World Applications Solve problems inspired by Lua's common use cases, such as game development and embedded systems.

Step-by-Step Guidance Break down Lua's concepts into digestible lessons.

Practical Skills Build hands-on experience with Lua for real-world projects.

Choose from the following categories