How to Solve "832 Flipping an Image" on LeetCode? - Javascript

Опубликовано: 07 Октябрь 2024
на канале: Coding David
180
5

Do you need more help with coding?
════════════════════════════
✅ Apply for 1-1 coaching https://form.jotform.com/230156286763056

Problem: 832 Flipping an Image
Language: #Javascript
Difficulty: Easy

Strategy: Loops
Time Complexity: O(n*m)
Space Complexity: O(1)

Pseudo Code:
1. Loop through image.
a. Create left pointer.
b. Create right pointer.
c. While left is less than right.
i. Replace the values in the left pointer with the ones in the right.
ii. Increment left.
iii. Decrement right.
2. Loop through image.
a. Nested loop.
i. Condition if value is 0.
1. Change to 1.
ii. Else if value is 1.
2. Change to 0.
3. Return image.

GitHub Repo:
https://github.com/anusontarangkul/le...

Let's Connect 💯:
════════════════════════════
LinkedIn:   / anusontarangkul  
TikTok:   / david.anu_  
Instagram:   / david.anu_  
GitHub: https://github.com/anusontarangkul