假设点P处于坐标轴原点,W表示向上,A表示向左,S表示向下,D表示向右,输入一串指令代表P点的移动轨迹,输出最终P的位置 例如 "2W2D"表示向上移动两个坐标位置,再向右移动两个坐标位置 "W2D"表示向上移动一个坐标位置,再向右移动两个坐标位置
示例1
输入
"2W2D"
输出
[2,2]
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ public int[] GetEndPoint (String order) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型vector */ vector
GetEndPoint(string order) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param order string字符串 # @return int整型一维数组 # class Solution: def GetEndPoint(self , order ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ public List
GetEndPoint (string order) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ function GetEndPoint( order ) { // write code here } module.exports = { GetEndPoint : GetEndPoint };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param order string字符串 # @return int整型一维数组 # class Solution: def GetEndPoint(self , order ): # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ func GetEndPoint( order string ) []int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 * @return int* returnSize 返回数组行数 */ int* GetEndPoint(char* order, int* returnSize ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param order string字符串 # @return int整型一维数组 # class Solution def GetEndPoint(order) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ def GetEndPoint(order: String): Array[Int] = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ fun GetEndPoint(order: String): IntArray { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ public int[] GetEndPoint (String order) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ export function GetEndPoint(order: string): number[] { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ func GetEndPoint ( _ order: String) -> [Int] { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param order string字符串 * @return int整型一维数组 */ pub fn GetEndPoint(&self, order: String) -> Vec
{ // write code here } }
"2W2D"
[2,2]