Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.
- Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.
- Note that elements beyond the length of the original array are lost.
- Do the above modifications to the input array in place, do not return anything from your function.
- Example 1:
- Input: [1,0,2,3,0,4,5,0]
- Output: null
- Explanation: After calling your function, the input array is modified to: [1,0,0,2,3,0,0,4]
- 2.
- Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
- You may assume that the array is non-empty and the majority element always exist in the array.
- Think of how you can store a pair with the number and its associated number of appearances.
- Example 1:
- Input: [3,2,3]
- Output: 3
- Example 2:
- Input: [2,2,1,1,1,2,2]
- Output: 2
- 3.
- Given a string, you need to reverse the order of characters in each word within a sentence while still preserving white space and initial word order.
- Example 1:
- Input: "Let's take LeetCode contest"
- Output: "s'teL ekat edoCteeL tsetnoc"
- Note: In the string, each word is separated by single space and there will not be any extra space in the string.
- 4.
- Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list
- You may return the answer in any order.
- Example 1:
- Input: ["bella","label","roller"]
- Output: ["e","l"]
- Example 2:
- Input: ["cool","lock","cook"]
- Output: ["c","o"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement