2018年5月16日 星期三

Leetcode - 657. Judge Route Circle

Question:
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.


Leetcode - 520. Detect Capital

Question
Given a word, you need to judge whether the usage of capitals in it is right or not.

We define the usage of capitals in a word to be right when one of 
the following cases holds:

1. All letters in this word are capitals, like "USA".
2. All letters in this word are not capitals, like "leetcode".
3. Only the first letter in this word is capital if it has more than one letter,
   like "Google".

Otherwise, we define that this word doesn't use capitals in a right way.

Leetcode - 1. Two Sum

Question:
Given an array of integers, 
return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution,
and you may not use the same element twice.

Leetcode - 283. Move Zeroes

Question:
Given an array nums, write a function to move all 0's to the end of it 
while maintaining the relative order of the non-zero elements.