Photo from Pixabay

iOS Interview Prep Guide: 30-Day Code Challenge in Swift — Week 4/5

Michael T. Ho
The Startup
Published in
12 min readMay 10, 2020

--

Here comes the fourth week of the challenge. Keep grinding. If you need to catch up a bit, you can find challenges of the previous weeks here — Week 1, Week 2, and Week 3

Also, feel free to utilize my Github repo that includes a solution and unit tests for each coding question of the code challenge.

In this article, we’ll discuss the following 7 programming questions from week 4 of the code challenge.

  1. Subarray Sum Equals K (Solution) 🥇
  2. Bitwise AND of Numbers Range (Solution)
  3. LRU Cache (Solution)
  4. Jump Game (Solution)
  5. Longest Common Subsequence (Solution) 🥉
  6. Maximal Square (Solution) 🥈
  7. First Unique Number (Solution)

(🥇 🥈 🥉 indicate writer’s selection of high-frequency interview questions.)

Subarray Sum Equals K

🥇 Writer’s selection of the week

Description: Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals k.

Example Input:nums = [1, 1, 1], k = 2
Output: 2

--

--