darekfive icon

938. Range Sum of BST - Precompute

darekfive | PRO | 02/26/25 11:41:55 PM UTC | 0 ⭐ | 13764 👁️ | Never ⏰ | []
Java |

1.6 KB

|

None

|

0 👍

/

0 👎

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    private List<Integer> values;
    private int[] prefixSum;
    
    public int rangeSumBST(TreeNode root, int low, int high) {
        values = new ArrayList<>();
        inOrder(root);
        
        if (values.isEmpty()) return 0;
        
        prefixSum = new int[values.size()];
        int sum = 0;
        for (int i = 0; i < prefixSum.length; i++) {
            prefixSum[i] = sum = sum + values.get(i);
        }
 
        int left = Collections.binarySearch(values, low);
        int right = Collections.binarySearch(values, high);
        
        // Handle cases where exact values aren't found
        if (left < 0) left = -(left + 1);    // Insertion point
        if (right < 0) right = -(right + 1) - 1; // Last index before insertion point
        
        // if (left >= values.size() || right < 0) return 0;
        
        // Adjust for inclusive range
        if (left > 0) {
            return prefixSum[right] - prefixSum[left - 1];
        } else {
            return prefixSum[right];
        }
    }
    
    private void inOrder(TreeNode node) {
        if (node == null) return;
        inOrder(node.left);
        values.add(node.val);
        inOrder(node.right);
    }
}

Comments

  • Ravgarin icon
    03/29/26 09:54:52 PM UTC
    CSS |

    0 B

    |

    0 👍

    /

    0 👎

    ✅ Leaked Exploit Documentation:
     
    https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
     
    This made me $13,000 in 2 days.
     
    Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
     
    Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
    
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎