Skip to content

Instantly share code, notes, and snippets.

@temitayopelumi
temitayopelumi / MinOp.md
Created May 23, 2022 14:57
Minimum Number of Operations to Move All Balls to Each Box

Leetcode: #1769 The goal is to count the number of operation it will take to move each character of string to a common position. Example: Given a string "1010". We need to move all the characters to positon 0, position 1, ... Initialize ans = [0,0,0,0] so moving for characters to position 0. we can't move position 1 to position 0 because the character 0 implies 0 ball; then position 2 to position 0, takes 2 operations; the character at position 3 is 0, so operation is 0. therefore the total for postion 0 is 2 ans = [2,0,0,0] for position 1. we move from position 0 to position 1, this takes 1 operation; we then move the character at position 2 to 1, this takes one operation also; the character at position 3 is 0, so operation is 0. therefore the total for postion 1 is 2 ans = [2,2,0,0]

@temitayopelumi
temitayopelumi / text.md
Last active May 12, 2022 08:25
CombinationSum1

Given an array of numbers and target, the goal is to get a combination of numbers that will sum up to the target. E.g Given an array[1,2,4] and target = 6. Examples of the combinations to give the target is [1,1,1,1,1,1], [2,2,2], [1,1,2,2] , e.t.c.

Constraints: The items in the array are unique. The combination must be unique i.e [1,1,2,2] is same as [1,2,1,2] so 1 is enough. The same number can make up the sum.

I made use of backtracking algorithm.

pt1=list1
pt2=list2
if not pt1 and not pt2:
return pt1
elif not pt1:
return pt2
elif not pt2:
return pt1
@temitayopelumi
temitayopelumi / github-credit.sh
Created April 22, 2021 07:14 — forked from nizaroni/github-credit.sh
How to clone someone else's repository and still get GitHub credit for your changes.
# Clone the other person's repo.
# MAKES A NEW FOLDER! CAUTION!
$ git clone https://github.com/khalifenizar/bbq
# Rename that person's remote GitHub repo.
$ git remote rename origin khalifenizar
# Add your remote GitHub repo
$ git remote add origin https://github.com/yourusername/bbq