[LeetCode] Walking Robot Simulation 走路机器人仿真

A robot on an infinite grid starts at point (0, 0) and faces north.? The robot can receive one of three possible types of commands:

  • -2: turn left 90 degrees
  • -1: turn right 90 degrees
  • 1 <= x <= 9: move forward?x?units

Some of the grid squares are obstacles.?

The?i-th obstacle is at grid point?(obstacles[i][0], obstacles[i][1])

If the robot would try to move onto them, the robot stays on the previous grid square instead (but still continues following the rest of the route.)

Return the?square?of the maximum Euclidean distance that the robot will be from the origin.

Example 1:

Input: commands = [4,-1,3], obstacles = []
Output: 25
Explanation: robot will go to (3, 4)

Example 2:

Input: commands = [4,-1,4,-2,4], obstacles = [[2,4]]
Output: 65
Explanation: robot will be stuck at (1, 4) before turning left and going to (1, 8)

Note:

  1. 0 <= commands.length <= 10000
  2. 0 <= obstacles.length <= 10000
  3. -30000 <= obstacle[i][0] <= 30000
  4. -30000 <= obstacle[i][1] <= 30000
  5. The answer is guaranteed to be less than?2 ^ 31.

参考资料:

https://leetcode.com/problems/walking-robot-simulation/

LeetCode All in One 题目讲解汇总(持续更新中...)

原文地址:https://www.cnblogs.com/grandyang/p/10800993.html

时间: 2024-11-06 07:45:35

[LeetCode] Walking Robot Simulation 走路机器人仿真的相关文章

leetcode 874 Robot Simulation

leetcode 874 Robot Simulation 限制:32MB, 1s 描述 A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: -2: turn left 90 degrees -1: turn right 90 degrees 1 <= x <= 9: move forw

【Leetcode_easy】874. Walking Robot Simulation

problem 874. Walking Robot Simulation 参考 1. Leetcode_easy_874. Walking Robot Simulation; 完 原文地址:https://www.cnblogs.com/happyamyhope/p/11252142.html

874.Walking Robot Simulation(list不可被哈希)

A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: -2: turn left 90 degrees -1: turn right 90 degrees 1 <= x <= 9: move forward x units Some of the grid squares are obst

874. Walking Robot Simulation

A robot on an infinite grid starts at point (0, 0) and faces north.  The robot can receive one of three possible types of commands: -2: turn left 90 degrees -1: turn right 90 degrees 1 <= x <= 9: move forward x units Some of the grid squares are obs

基于 Mathematica 的机器人仿真环境(机械臂篇)[转]

完美的教程,没有之一,收藏学习. 目的 本文手把手教你在 Mathematica 软件中搭建机器人的仿真环境,具体包括以下内容(所使用的版本是 Mathematica 11.1,更早的版本可能缺少某些函数,所以请使用最新版.[email protected]).  1 导入机械臂的三维模型  2 (正/逆)运动学仿真  3 碰撞检测  4 轨迹规划  5 (正/逆)动力学仿真  6 控制方法的验证  不妨先看几个例子: 逆运动学 双臂协作搬运 显示运动痕迹 (平移)零空间运动  无论你是从事机器

ROS和Gazebo进行机器人仿真(一)

Gazebo是一种多机器人仿真器,可用于室内外机器人仿真.Gazebo在ROS中有良好的接口,包含ROS和Gazebo的所有控制. 若要实现ROS到Gazebo的通信,我们必须安装ROS-Gazebo接口. 应该安装以下软件包: $ sudo apt install ros-melodic-gazebo-ros-pkgs  ros-melodic-gazebo-msgs  ros-melodic-gazebo-plugins  ros-melodic-gazebo-ros-control *ga

在ROS中开始自主机器人仿真 - 1 概述

建立自主机器人是很难的,特别是在刚开始的时候. ROS 仿真有助于帮助我们从宏观上对机器人系统进行把握,帮助我们学习如何可以让机器人学会自己去适应环境. 明白机器人从测量和激光数据采集到转变为电机运动的过程. 机器人如何利用传感器进行感知, 找出好的路径, 应该执行什么样的命令. 这不是一套完整的自主机器人仿真的指导内容,但希望是一个好的开始. 所介绍的是小项目的一部分, 主要集中于如何开始自己的自主机器人仿真. 首先, 我们用ROS自带的turtlebot库,让机器人跑起来,这样我们有了直观的

[LeetCode] 489. Robot Room Cleaner 扫地机器人

Given a robot cleaner in a room modeled as a grid. Each cell in the grid can be empty or blocked. The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is 90 degrees. When it tries to move into a blocked cel

在ROS中开始自主机器人仿真 - 4 建立自己的自主机器人URDF模型

要建立自己的自主机器人,首先,必须要建立自己的机器人模型,URDF(Unified Robot Description Format)模型. part 3 建立自主机器人URDF模型 机器人URDF模型主要由两个文件组成:.xacro 是主文件,包含URDF项,包括关节,连杆:.gazebo包含gazebo的具体信息以便在gazebo中仿真. 例子请见:How to Build a Differential Drive Simulation 以下工程的源码下载地址请见: http://downl