Browse Source

add array questions

Froilan Miranda 6 years ago
parent
commit
ed4ca71ff7
1 changed files with 17 additions and 0 deletions
  1. 17
    0
      Arrays.md

+ 17
- 0
Arrays.md View File

@@ -0,0 +1,17 @@
1
+# Array Questions
2
+*How to merge sorted array? (this could be a follow up to sorting an array)*
3
+Given two sorted integer arrays A and B, merge B into A as one sorted array. You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. The number of elements initialized in A and B are m and n respectively.
4
+
5
+*How to find minimum value in a rotated sorted array?*
6
+Suppose a sorted array is rotated at some pivot unknown to you beforehand.
7
+
8
+(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
9
+
10
+Find the minimum element.
11
+
12
+You may assume no duplicate exists in the array. One follow-up question of this question is What if duplicates are allowed? Would this affect the run-time complexity? How and why?
13
+
14
+
15
+*Given an array of of size n and a number k, find all elements that appear more than n/k times?*
16
+You are given an array of size n, find all elements in array that appear more than n/k times. For example, if the input arrays is {3, 1, 2, 2, 1, 2, 3, 3} and k is 4, then the output should be [2, 3]. Note that size of array is 8 (or n = 8), so we need to find all elements that appear more than 2 (or 8/4) times. There are two elements that appear more than two times, 2 and 3.
17
+