LeetCode: Flipping an Image Solution

Bit flip made easy with coercion

Approach

For each row, reverse and flip bit

Bit flip made simple with coercion

11 - '1' = 0
21 - '0' = 1

Implementation

1var flipAndInvertImage = function (image) {
2 return image.map(row => row.reverse().map(el => 1 - el))
3}

References

Original problem

Comments

Loading comments...

Tags

leetcode

array

string

Next Post

LeetCode: Ugly Number

Jul 20, 2022

Recursively dividing

Previous Post

CSSBattle 16.95: Pokeball

Nov 20, 2021

Multiple background images, gradient

HoningJS

Search Posts