# Coding Problems and Solutions-5

`Input:nums = [1,1,1], k = 2Output: 2`
`Input: houses = [1,4,8,10,20], k = 3Output: 5Explanation: Allocate mailboxes in position 3, 9 and 20.Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5`
`Input: arr = [3,2,2,4,3], target = 3Output: 2Explanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.`
`Input: bloomDay = [1,10,3,10,2], m = 3, k = 1Output: 3Explanation: Let's see what happened in the first three days. x means flower bloomed and _ means flower didn't bloom in the garden.We need 3 bouquets each should contain 1 flower.After day 1: [x, _, _, _, _]   // we can only make one bouquet.After day 2: [x, _, _, _, x]   // we can only make two bouquets.After day 3: [x, _, x, _, x]   // we can make 3 bouquets. The answer is 3.`
`Input: arr = [4,3,1,1,3,3,2], k = 3Output: 2Explanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.`
`'A' -> 1'B' -> 2...'Z' -> 26`
`Input: "12"Output: 2Explanation: It could be decoded as "AB" (1 2) or "L" (12).`
`Input:s: "cbaebabacd" p: "abc"Output:[0, 6]Explanation:The substring with start index = 0 is "cba", which is an anagram of "abc".The substring with start index = 6 is "bac", which is an anagram of "abc".`
1. Only one letter can be changed at a time.
2. Each transformed word must exist in the word list.
• Return 0 if there is no such transformation sequence.
• All words have the same length.
• All words contain only lowercase alphabetic characters.
• You may assume no duplicates in the word list.
• You may assume beginWord and endWord are non-empty and are not the same.
`Input:beginWord = "hit",endWord = "cog",wordList = ["hot","dot","dog","lot","log","cog"]Output: 5Explanation: As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog",return its length 5.`
`Input: [23, 2, 4, 6, 7],  k=6Output: TrueExplanation: Because [2, 4] is a continuous subarray of size 2 and sums up to 6.`
`Input: numCourses = 2, prerequisites = [[1,0],[0,1]]Output: falseExplanation: There are a total of 2 courses to take.              To take course 1 you should have finished course 0, and to take course 0 you should             also have finished course 1. So it is impossible.`
`Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list becomes 1->2->3->5.`

--

--

## More from Abhijit Mondal

Engineer

Love podcasts or audiobooks? Learn on the go with our new app.