Light Switch Rank Problem

Light Switch Rank Problem — ExecCode Hard DSA Practice

Solve the Light Switch Rank problem on ExecCode. Free online hard DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Each row is a light-switch pattern over GF(2) (0/1). The rank of the matrix is how many independent equations you have — Gaussian elimination with XOR. That rank is also the size of a linear basis of the row-masks. Each row is a 0/1 list. Return the GF(2) rank. You are given: rows — 0/1 matrix Return rank. Two identical rows contribute 1.

Examples

Input {'rows': [[1, 0], [0, 1]]}; Output 2. Input {'rows': [[1, 1], [1, 1]]}; Output 1. Input {'rows': [[0, 0]]}; Output 0

Constraints

Rows may have equal length in tests Zero rows do not add rank

Practice Light Switch Rank free on ExecCode. Browse DSA problems, topic map, and placement guides.