Posts

Showing posts from June, 2024

Last number of Range Theory for For Loops

 for i in range(n,0,-1):   It runs from n to 1. Because what I think is that the third argument of the for is by default 1 and if we pass something then it take that as an argument So, what I think is that the formula for last element of the loop is: lastElement = lastNumber - lastArgument for i in range(n): In this first number is by default 0 and last number is  lastElement = n - 1(By default it is 1) For reverse loops: lastElement = n - (-1)      = n + 1 So for above Straight Loop: Iterator will move from 1 to n-1 and for Reverse Loop: Iterator will move from n to 1

8 Patterns to solve 80% of LeetCode problems

 8 Patterns to solve 80% of LeetCode problems: 1. Sliding Window 2. Subset Pattern 3. Modified Binary Search 4. Top K Elements 5. Binary Tree DFS 6. Topological Sort 7. Binary Tree BFS 8. Two Pointers

How to merge branches when you see "merge locally" in Git

Image
How to merge branches when you see "merge locally" in Git When branches have issues on GUI while merging: Run following commands: 1. git checkout main_branch 2. git merge feature_branch 3. git rebase -- continue If git rebase have issues: git status git fetch origin git log main_branch -1 git rebase --abort git rebase origin/main_branch git add . git rebase --continue