题目介绍 一次遍历 public class Solution { public int MaxProfit(int[] prices) { int s=0; for(int i=0;i<prices.Length-1;i++) { if(prices[i]<=prices[i+1]) { s+=prices[i+1]-prices[i]; } else { s+=0; } } return s; } }