加载中...
分类详情
中等 分类
LCP 03-机器人大冒险(Programmable Robot)
原文链接: https://leetcode-cn.com/problems/programmable-robot 中文题目力扣团队买了一个可编程机器人,机器人初始位置在原点(0, 0)。小伙伴事先给机器人输入一串指令command,机器人就会无限循环这条指令的步骤进行移动。指令有两种: U: 向y轴正方向移动一格 R: 向x轴正方向移动一格。 不幸的是,在 xy 平面上还有一些障碍物,他们的坐标用obstacles表示。机器人一旦碰到障碍物就会被损毁。 给定终点坐标(x, y),返回机器人能否…
2021-12-03
面试题 05.04-下一个数(Closed Number LCCI)
原文链接: https://leetcode-cn.com/problems/closed-number-lcci 英文原文Given a positive integer, print the next smallest and the next largest number that have the same number of 1 bits in their binary representation. Example1: Input: num = 2 (0b10) Output: [4…
2021-12-03
面试题 02.05-链表求和(Sum Lists LCCI)
原文链接: https://leetcode-cn.com/problems/sum-lists-lcci 英文原文You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a …
2021-12-03
面试题 03.03-堆盘子(Stack of Plates LCCI)
原文链接: https://leetcode-cn.com/problems/stack-of-plates-lcci 英文原文Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshol…
2021-12-03
面试题 08.04-幂集(Power Set LCCI)
原文链接: https://leetcode-cn.com/problems/power-set-lcci 英文原文Write a method to return all subsets of a set. The elements in a set are pairwise distinct. Note: The result set should not contain duplicated subsets. Example: Input: nums = [1,2,3] Output: […
2021-12-03
面试题 08.11-硬币(Coin LCCI)
原文链接: https://leetcode-cn.com/problems/coin-lcci 英文原文Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents), and pennies (1 cent), write code to calculate the number of ways of representing n cents. (The result may be la…
2021-12-03
面试题 16.01-交换数字(Swap Numbers LCCI)
原文链接: https://leetcode-cn.com/problems/swap-numbers-lcci 英文原文Write a function to swap a number in place (that is, without temporary variables). Example: Input: numbers = [1,2] Output: [2,1] Note: numbers.length == 2 -2147483647 <= numbers[i] <= 21474…
2021-12-03
剑指 Offer 04-二维数组中的查找(二维数组中的查找 LCOF)
原文链接: https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof 中文题目在一个 n * m 的二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个高效的函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 示例: 现有矩阵 matrix 如下: [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 2…
2021-12-03
剑指 Offer 12-矩阵中的路径(矩阵中的路径 LCOF)
原文链接: https://leetcode-cn.com/problems/ju-zhen-zhong-de-lu-jing-lcof 中文题目给定一个 m x n 二维字符网格 board 和一个字符串单词 word 。如果 word 存在于网格中,返回 true ;否则,返回 false 。 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母不允许被重复使用。 例如,在下面的 3×4 的矩阵中包含单词 "ABCCED…
2021-12-03