11 short programming problems to stretch your imagination and make sure you are staying on your toes.

(Starting with the simple ones, they get more fun as you move towards the end.)

🧵👇

1. Write a function that reverses an array in place.

In other words, the function should not use an auxiliary array to do the work.
2. Write a function that finds the missing number in an unsorted array containing every one of the other 99 numbers ranging from 1 to 100.
3. Write a function that finds the duplicate number in an unsorted array containing every number from 1 to 100.

Only one of the numbers will appear twice.
4. Write a function that removes every duplicate value in an array.

There could be more than one value duplicated. You should remove all of them leaving a single copy of the value.
5. Write a function that finds the largest and smallest number in an unsorted array.
6. Write a function that finds a subarray whose sum is equal to a given value.
7. Write a function that finds the contiguous subarray of a given size with the largest sum.
8. Write a function that, given two arrays, finds the longest common subarray present in both of them.
9. Write a function that, given two arrays, finds the length of the shortest array that contains both input arrays as subarrays.
10. Write a function that, given an array, determines if you can partition it in two separate subarrays such that the sum of elements in both subarrays is the same.
11. Write a function that, given an array, divides it into two subarrays, such as the absolute difference between their sums is minimum.
I'd love to see some answers!

If you want more content on software engineering, machine learning, and adjacent topics, give me a follow. I post threads like this every week. You can enjoy more of this content here: @svpino.

More from Santiago

More from Tech

1. One of the best changes in recent years is the GOP abandoning libertarianism. Here's GOP Rep. Greg Steube: “I do think there is an appetite amongst Republicans, if the Dems wanted to try to break up Big Tech, I think there is support for that."

2. And @RepKenBuck, who offered a thoughtful Third Way report on antitrust law in 2020, weighed in quite reasonably on Biden antitrust frameworks.

3. I believe this change is sincere because it's so pervasive and beginning to result in real policy changes. Example: The North Dakota GOP is taking on Apple's app store.


4. And yet there's a problem. The GOP establishment is still pro-big tech. Trump, despite some of his instincts, appointed pro-monopoly antitrust enforcers. Antitrust chief Makan Delrahim helped big tech, and the antitrust case happened bc he was recused.

5. At the other sleepy antitrust agency, the Federal Trade Commission, Trump appointed commissioners
@FTCPhillips and @CSWilsonFTC are both pro-monopoly. Both voted *against* the antitrust case on FB. That case was 3-2, with a GOP Chair and 2 Dems teaming up against 2 Rs.

You May Also Like