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

Recursively dividing

Previous Post

CSSBattle 16.95: Pokeball

Multiple background images, gradient

HoningJS

Search Posts