Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  1. Code Block
    languagejava
    titletime out
    		int max = nums[0];
            for (long i = 0; i < nums.length; i++) {
    
                for (long j = 1; j <= nums.length - i; j++) {
                    final int value = Arrays.stream(nums)
                            .boxed()
                            .mapToInt(Integer::intValue)
                            .skip(i)
                            .limit(j)
                            .sum();
    
                    if (value > max) {
                        max = value;
                    }
                }
            }
    		return max;


    회고 (*참고 자료 : [카데인 알고리즘] https://medium.com/@vdongbin/kadanes-algorithm-%EC%B9%B4%EB%8D%B0%EC%9D%B8-%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98-acbc8c279f29)

    Code Block
    languagejava
    		public int max = nums[0];
    
            final int asInt = Arrays.stream(maxSubArray(int[] nums) {
            /**
          .max()                 .getAsInt();
    
    
    * sum(nums[i-1]) + num[i], num[i]
           int maxIndex =*/
    0;         for (int i = 01; i < nums.length; i++) {
                if nums[i] = Math.max(nums[i], == asInt) {
     nums[i - 1] + nums[i]);
            }
         maxIndex = i; return Arrays.stream(nums)
                  break;  .max()
              }      .getAsInt();
      }
    
    
         }
  2. 회고 [dp의 작은 문제 찾기 : (n 번째 계단을 오르는 경우) = (n-1 번째 계단을 오르는 경우) + (n-2 번째 계단을 오르는 경우)]

    Code Block
    languagejava
    public int climbStairs(int n) {
        for (int i = 1;if i(n < nums.length - maxIndex + 1; i++3) {
                finalreturn intn;
    value = Arrays.stream(nums)      }
    
            int[] ways = new  .boxed()
    int[n + 1];
            ways[1] = 1;
            .mapToInt(Integer::intValue)
     ways[2] = 2;
    
            for (int i = 3; i <=   .skip(maxIndexn; i++) {
                ways[i] = ways[i - 1]   .limit(i)
     + ways[i - 2];
            }
             .sum()return ways[n];
        }
  3. 회고 (실패.. 다시 도전 중)

    Code Block
    languagejava
    public         if (value > maxint rob(int[] nums) {
    
            if (nums.length == 0) {
      max = value;        return 0;
       }         }
    
            if for (intnums.length i == -1 ; i > -maxIndex ; i--) {
                final int value = Arrays.stream(nums)return nums[0];
            }
    
            if  .boxed()
      (nums.length < 3) {
                return     .mapToInt(Integer::intValue)Math.max(nums[0], nums[1]);
            }
    
            for  .skip(maxIndex)int i = 2; i <                .limit(i)
    nums.length; i++) {
                nums[i] = nums[i] + nums[i   .sum()- 2];
            }
    
        if (value > max) {
                    max = valuereturn Math.max(nums[nums.length - 1], nums[nums.length - 2]);
                }
            }
    		return max;
  4. ..
  5. ..