Hi Geeks, I have applied for Google SWE Internship 2021 (India) and I have been selected and invited for Google’s Online Challenge Round
Application: I have applied through LinkedIn, it is really a great platform for opportunities and I received mail from Google on 12 Aug 2020 and it was a great experience for me.
I am here to share questions that have been asked in coding challenges. I hope I will help you.
Question 1: Array queries: You are given an array of integers whose length is N, you must perform the following five types of query on the given array :
- Left: Perform one cyclic left rotation.
- Right: Perform one cyclic right rotation.
- Update Pos Value: Update the value at index Pos of the array by Val.
- Increment Pos: Increment value at index Pos of the array by 1.
- Pos: Print the current value at index Pos.
All the queries are performed considering 1-based indexing.
- One cyclic left rotation changes (arr1, arr2, arr3, . . . , arrN-1, arrN) to (arr2, arr3, . . .arrN-1, arrN, arr1).
- One cyclic right rotation changes (arr1, arr2, arr3, . . . , arrN-1, arrN) to (arrN, arr1, arr2, arr3, . . .arrN-1).
- The first line contains an integer N denoting the length of the array.
- The second line contains N space-separated integers denoting the elements of the array.
- The third line contains an integer Q denoting the number of queries.
- Next, Q lines contain the described type of query.
Output format: For each query of type 5, print the output in a new line.
2 ≤ N ≤ 5 x 105 2 ≤ Q ≤ 5 x 105 1 ≤ Pos ≤ N 0 ≤ arri , Val ≤ 105
It is guaranteed that at least one query is of type 5.
Sample Input 1
10 0 3 3 8 0 6 9 3 2 8 10 Increment 3 Increment 1 Left Increment 5 Left ? 9 Right
Sample Output 1
Question 2:There are N-words in a dictionary such that each word is of fixed length M and consists of only lowercase English letters that are (‘a’, ‘b’, ……. ‘z’).
A query word denoted by Q. The length of query word in M. These words contain lowercase English letters but at some places instead of a letter between ‘a’, ‘b’, ……. ‘z’ there is ‘?’ .Refer to the Sample input section to understand this case.
A match count of Q, denoted by match_count(Q), is the count of words that are is the dictionary and contain the same English letters (excluding a letter that can be in the position of ?) in the same position as the letters are there are in the query word Q.
In other words, a word in the dictionary can contain any letters at the position ‘?’ but the remaining alphabets must match with the query word.
You are given a query word Q and you are required to compute match_count(Q).
- First-line contains two space-separated integers M and N denoting the number of words in the dictionary and length of each word respectively.
- The next N lines contain one word each from the dictionary.
- The next line contains an integer Q denoting the number of query words for which u have to compute match_count()
- The next Q lines contain one query word each.
For each query word, print match_count for specific words in a new line.
1 ≤ N ≤ 5 x 104 1 ≤ M ≤ 7 1 ≤ Q ≤ 105
5 3 cat map bat man pen 4 ?at ma? ?a?
2 2 4 2