本帖最后由 匿名 于 2023-9-29 21:09 编辑
leetcode 原题:
题目:
Given an array nums which consists of only '0's and '1's where '1' denotes there's a stone at a given position, an index p, and an integer k. Find the minimum steps needed to stack at least k stones at position p. Within one step, you're only allowed to move one stone to an adjacent position.
# nums: [1,0,1,0,0,1]
# k: 2
# p: 2
# result=2
Followup:# Given an array nums which consists of only '0's and '1's where '1' denotes there's a stone at given position, and an integer k. Find the minimum steps needed to stack at least k stones. Within one step, ̴6] 中位数是5 求 这个最大值是什么 -
解题思路 :二分查找-
第三题:
有一个 linklist 5 - 3 - 2, - 4 - 1 - 8 - 2 - 1 - 3 - 4 - 6, 和 target 3 给出一个新的linklist 是由 小于 target 等于 target 大于 target 拼在一起
比如说 上面 output 就是 2 - 1 - 2 - 1 - 3 - 3 - 5 - 4 - 8 - 4 - 6
解题:定义三个临时头节点,然后while loop
sd题目:
补充内容 (2023-09-30 10:11 +08:00):
第一次排版有点乱。 |