- InstaByte
- Posts
- 5 Git Commands You Must Know
5 Git Commands You Must Know
ALSO: Uber Interview Problem
Welcome back!
This week's problem looks simple. But when you try to solve it, it's a real brain-bender.
Hereโs what to expect today:
Set Matrix Zeroes problem
Git Commands You Must Know
Read time: under 4 minutes
CODING CHALLENGE
Set Matrix Zeroes
Given an m x n
integer matrix matrix
, if an element is 0
, set its entire row and column to 0
's. You must do it in place.
Example 1:
Input: matrix = [[1,1,1],[1,0,1],[1,1,1]]
Output: [[1,0,1],[0,0,0],[1,0,1]]
Example 2:
Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
Output: [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
Solve the problem here before reading the solution.
PRESENTED BY 1440
We scour 100+ sources daily
Read by CEOs, scientists, business owners and more
3.5 million subscribers
SOLUTION
We'll use the first row and first column of the matrix as markers. These markers will keep track of which rows and columns need to be set to zero.
First, we'll check if the first row and first column need to be zeroed out. Then, we'll iterate through the rest of the matrix. Weโll mark the first row and the first column elements as 0
if we encounter a zero.
Finally, we'll use these markers to set the appropriate elements to zero. This approach allows us to solve the problem in-place without using extra space.
The time complexity of this solution is O(m * n)
, where m
is the number of rows and n
is the number of columns in the matrix.
COMMUNITY
InstaByte Question Bank
๐ง Help each other by sharing the actual questions you were asked in a recent interview. Use this form to submit your question.
We will share the submitted questions on this weekly newsletter - stay tuned!
Note: Your submission is anonymous.
CHEAT SHEET
Git Commands You Must Know
This cheat sheet contains commands that are well known. Here are 5 lesser known but useful Git commands:
1. git rebase: Combines changes from one branch into another, keeping your commit history clean and organized.
2. git fetch: Downloads new changes from a remote repository to your local machine without automatically applying them.
3. git cherry-pick: Applies a single commit from one branch to another, allowing you to move specific changes where needed.
4. git stash: Temporarily saves your work-in-progress without committing. It is useful for quickly switching branches when you have pending changes.
5. git bisect: Helps find the commit that introduced a bug by using a binary search algorithm, efficiently narrowing down the problematic commit.
NEWS
This Week in the Tech World
Source: AOP Press/Corbis via Getty Images
Telegram CEO Charged in France: Pavel Durov, Telegram's CEO, faces charges in France for allegedly enabling criminal activity on the platform. He's been in custody since Saturday and posted โฌ5 million bail.
Google Relaunches AI Image Generator: Google is set to reintroduce its AI image generation tool for people after addressing previous inaccuracies. The updated Imagen 3 will be available to Gemini users in the coming days.
Nokia Brand Launches Barbie Phone: HMD, the Nokia brand owner, released a $130 Barbie-themed flip phone without internet connectivity, targeting the growing "digital detox" trend among Gen Z consumers.
Zuckerberg Claims White House Pressured Meta: Meta CEO Mark Zuckerberg alleged the Biden administration pressured the company to censor COVID-19 content in 2021, expressing regret over some content moderation decisions.
Appleโs Glowtime: Apple announced its annual fall event for September 9, where it's expected to unveil new iPhone and Apple Watch models. The event's tagline is "It's Glowtime."
Tech Entrepreneur Mike Lynch Dies: Mike Lynch, founder of Autonomy and once dubbed "Britain's Bill Gates," was found dead at 59 in a yacht wreck off Sicily's coast, just two months after winning a U.S. fraud trial.
OpenAI in Talks for $100B Valuation: OpenAI is reportedly discussing a funding round that would value the AI startup at over $100 billion. Thrive Capital is expected to lead with a $1 billion investment.
HELP US
๐ Hi there! We are on a mission to provide as much value as possible for free. If you want this newsletter to remain free, please help us grow by referring your friends:
๐ Share your referral link on LinkedIn or directly with your friends.
๐ Check your referrals status here.
BONUS
Just for laughs ๐
YOUR FEEDBACK
What did you think of this week's email?Your feedback helps us create better emails for you! |
Until next time, take care! ๐
Cheers,