014.Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
Write a function to find the longest common prefix string amongst an array of strings.
Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
Follow up for “Remove Duplicates”:
What if duplicates are allowed at most twice?
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
You are playing a game of dice with a friend. Your friend will roll one die, and you must pay the hunber of dollars for the number they roll. What should you charge you friend to play this game, if you want to break even in the long run? This value is the “fair value” of the game. It’s easy to see that for a one roll game, the fair value is 3.5
Given a number, return true if this number is the total number of elements in a 3D array or false if it’s not. For each dimension, the number of elements should be at least 2, i.e., the smallest number that is the size of a 3D array is 8.
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.