Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Write a function to find the longest common prefix string amonst an array of strings.
If there is no common prefix, return an empty string "".
Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.
The move sequence is represented by a string. And each move is represent by a character. The valid robot moves are R (Right). L
(Left), U
(Up) and D
(down). The output should be true or false representing whether the robot makes a circle.
題目
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.
題目
Given an integer array, find three numbers whose product is maximum and output the maximum product.
題目
Given an array of intergers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.
題目
Given a non-negative integer num
, repeatedly add all its digits until the result has only one digit.
題目
You are given a string representing an attendance record for a student. The record only contains the following three characters:
題目
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋
times.