摘要: 问题: 给定一棵树,root=0 每个节点id有值nums[id] 求每个节点的所有祖先中,最近&&与其值互质的父节点。 Example 1: Input: nums = [2,3,3,2], edges = [[0,1],[1,2],[1,3]] Output: [-1,0,0,1] Explan 阅读全文
posted @ 2021-03-17 15:42 habibah_chang 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定n*m二维数组grid,要求从左上角(0,0)->右下角(n-1,m-1) 移动规则:grid[i][j] 1:right -> grid[i][j + 1] 2:left -> grid[i][j - 1] 3:down -> grid[i + 1][j] 4:up -> grid[i 阅读全文
posted @ 2021-03-17 12:42 habibah_chang 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 问题: 跳棋游戏。 在一维数组arr中,从index=0开始, 下一步可以跳到:(在数组范围内) index+1 index-1 index_j : arr[index_j]=arr[index] 求最快跳到最后一格arr.size()-1的位置,需要多少步。 Example 1: Input: a 阅读全文
posted @ 2021-03-17 11:00 habibah_chang 阅读(170) 评论(0) 推荐(0) 编辑