# 📰 "Stay afraid, but do it anyway. What's important is the action. You don't have to wait to be confident. Just do it and eventually the confidence will follow." - Carrie Fisher

The Coding Puzzle 🧩

Last week’s puzzle:

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Example 1:

Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1].

Example 2:

Input: nums = [3,2,4], target = 6 Output: [1,2]

Solution for last week:

class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ required = {} for i in range(len(nums)): if target - nums[i] in required: return [required[target - nums[i]],i] else: required[nums[i]]=i input_list = [2,8,12,15] ob1 = Solution() print(ob1.twoSum(input_list, 20))

This week’s puzzle:

Given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn’t contain a binary gap.

Examples:

Given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap is of length 5.

Given N = 32 the function should return 0, because N has binary representation ‘100000’ and thus no binary gaps.

Developer Shares & Headlines 📢

❇️ How To Create A GitHub Profile README

❇️ We need to regulate mind-reading tech before it exists

❇️ 9 Common Coding Interview Questions and the Skills They Test For

Want to recommend someone for our developer spotlight, developer event, or just say hello? Send us an email at yourfriends@devslike.us we want to hear from you!

Social 💻

YouTube | Podcast | Instagram | Website | Twitter

The Cast on Twitter: Terrence | Clarence | JB

Well, that’s all we have for this week’s issue. A quick reminder to add our Podcast on your favorite platform and subscribe to our YouTube page!

Sincerely,

The DLU Team