Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. 1.
  2. Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.
  3. Note that elements beyond the length of the original array are lost.
  4. Do the above modifications to the input array in place, do not return anything from your function.
  5.  
  6. Example 1:
  7.  
  8. Input: [1,0,2,3,0,4,5,0]
  9. Output: null
  10. Explanation: After calling your function, the input array is modified to: [1,0,0,2,3,0,0,4]
  11.  
  12. 2.
  13. Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
  14. You may assume that the array is non-empty and the majority element always exist in the array.
  15. Think of how you can store a pair with the number and its associated number of appearances.
  16.  
  17. Example 1:
  18.  
  19. Input: [3,2,3]
  20. Output: 3
  21. Example 2:
  22.  
  23. Input: [2,2,1,1,1,2,2]
  24. Output: 2
  25.  
  26. 3.
  27. 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.
  28.  
  29. Example 1:
  30. Input: "Let's take LeetCode contest"
  31. Output: "s'teL ekat edoCteeL tsetnoc"
  32.  
  33. Note: In the string, each word is separated by single space and there will not be any extra space in the string.
  34.  
  35. 4.
  36. 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
  37.  
  38. You may return the answer in any order.
  39.  
  40. Example 1:
  41.  
  42. Input: ["bella","label","roller"]
  43. Output: ["e","l"]
  44. Example 2:
  45.  
  46. Input: ["cool","lock","cook"]
  47. Output: ["c","o"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement