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 "".
題目
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
Question
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.
Question
Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.
題目
Given an array of integers, 1 <= a[i] <= n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array.
題目
For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page's area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:
題目
Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is increasing a selected element by 1 or decrementing a selected element by 1.
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the fartheast leaf node.
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.
題意
Write an algorithm to determine if a number is "happy".
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.
Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two's complement method is used.
題意
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
題意
Given an array of integers, every element appears twice except for one. Find the single one.
Note:
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.
Both of you are very clever and have optimal stratgies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.
Given an array of integers where 1 <= a[i] <= n (n=size of array), some elements appear twice and others appear once.
Find all the elements of [1, n] inclusive that do not appear in this array.