Given an array of numbers, you need to duplicate the zero’s in the array. Do not extend the size of array, just discard the remaining elements (had array gets extended, those elements) after the array size. Example: Input: [1, 0, 2, 3, 0, 4, 5, 0] Output: [1, 0, 0, 2, 3, 0, 0, 4] Input: [1, 0, 0, 0, 3, 4, 5] Output: [1, 0, 0, 0, 0, 0, 0] Input: [1, 2, 3] Output: [1, 2, 3] Input: [0, 0, 0] Output: [0, 0, 0]
GIven an array of numbers, find out if array contains three consecutive odd numbers Example: [2, 4, 1, 3, 4, 1, 3, 6] Three consecutive odds: false [2, 4, 1, 3, 4, 1, 3, 6] Three consecutive odds: true [2, 4, 1, 3, 4, 1, 3, 6] Three consecutive odds: true
Given an array of numbers, write a program to rank the array elements. Example: Given array: [22, 11, 44, 66, 55] Rank: [2, 1, 3, 5, 4] Given array: [15, 12, 11, 10, 9] Rank: [5, 4, 3, 2, 1] Given array: [10, 20, 30, 40, 50] Rank: [1, 2, 3, 4, 5] Given array: [10, 10, 10, 10, 20] Rank: [1, 1, 1, 1, 2]
You are on a business trip and traveling from one city to another. you have a stack of unsorted flight boarding passes. The only departure city and destination city are on the boarding pass. how do you find the first departure city and your final destination city, Example: [Dallas, Austin], [Houston, Dallas], [Austin, Seattle] Output: Departure: Houston, Destination: Seattle [Dallas, New York], [Dallas, Austin], [Austin, Dallas], [New York, Seattle], [Seattle, Houston] Output: Departure: Dallas, Destination: Houston
Given a list of 24-hour clock time points in “HH:MM” format. Write a program to find the minimum minutes difference between any two time-points in the list. Example1: Given hours: [00:00, 03:00, 22:30] minimum time difference: 90 Example2: Given hours: [01:59, 03:00, 21:50, 22:30] minimum time difference: 40
Given an array write an algorithm to find the sum of all the possible sub-arrays. Example: int[] arr = {1, 2, 3}; Output: 20
Given an array of integers, find out duplicates in it. Example1: int[] arr = {4, 6, 2, 1, 2, 5}; Output: [2] Example2: int[] arr = {1, 6, 5, 2, 3, 3, 2}; Output: [2 , 3]
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] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2: Input: nums = [3,2,4], target = 6 Output: [1,2] Example 3: Input: nums = [3,3], target = 6 Output: [0,1]
Concatenation of Array