【leetcode_easy_array】1299. Replace Elements with Greatest Element on Right Side

problem

1299. Replace Elements with Greatest Element on Right Side

solution1: 使用元素交换;

code

 

solution2: 使用最大值求解;

code

 

solution3: 使用多目运算;

code

 

注意:

1. 末尾元素,以及最大值的初始化;

2. 使用倒序循环,以及赋值时计算数据的下标;

3. 求解最大值,以及赋值的过程;

参考

1. leetcode_1299. Replace Elements with Greatest Element on Right Side;

posted on 2020-07-15 22:45  鹅要长大  阅读(116)  评论(0编辑  收藏  举报

导航