• May 15, 2025 •AustinLeath
0 likes • 2 views
import java.util.Arrays; public class Main { public static int findMinNonCreatableSum(int[] coins) { // Sort the array Arrays.sort(coins); // Initialize max creatable sum int maxCreatable = 0; // Iterate through coins for (int coin : coins) { // If current coin is greater than maxCreatable + 1, // we found our answer if (coin > maxCreatable + 1) { return maxCreatable + 1; } // Add current coin to maxCreatable maxCreatable += coin; } // If we can create all sums up to maxCreatable, // the answer is maxCreatable + 1 return maxCreatable + 1; } public static void main(String[] args) { int[] coins = {2, 9, 1, 2, 7}; int result = findMinNonCreatableSum(coins); System.out.println("Smallest sum that cannot be created: " + result); } }
• Feb 6, 2021 •Daedalus
0 likes • 0 views
import java.util.Scanner; /* In Heaven, the seed is tall and the oak small / It's input vital * "The al-Madinatian," verse 236-37 * tinyurl.com/17snqkfv * email answer to [email protected] **/ public class Main { public static void main(String args[]) { int x = 0; int a, c, m = 10000; Scanner in = new Scanner(System.in); System.out.println("Please enter a seed, maximum 3000000:"); x = in.nextInt(); System.out.println("Please input a number, maximum 29:"); a = in.nextInt(); System.out.println("Please input a number, maximum 999999:"); c = in.nextInt(); char menu = 'y'; while(menu != 'n') { x = (a*x + c) % m; System.out.println("The next number is " + x + "\nWould you like another? (y/n)"); menu = in.next().charAt(0); } } } //██╗ ░█████╗░███╗░░░███╗ ██████╗░░█████╗░███████╗██████╗░░█████╗░██╗░░░░░██╗░░░██╗░██████╗ //██║ ██╔══██╗████╗░████║ ██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗██║░░░░░██║░░░██║██╔════╝ //██║ ███████║██╔████╔██║ ██║░░██║███████║█████╗░░██║░░██║███████║██║░░░░░██║░░░██║╚█████╗░ //██║ ██╔══██║██║╚██╔╝██║ ██║░░██║██╔══██║██╔══╝░░██║░░██║██╔══██║██║░░░░░██║░░░██║░╚═══██╗ //██║ ██║░░██║██║░╚═╝░██║ ██████╔╝██║░░██║███████╗██████╔╝██║░░██║███████╗╚██████╔╝██████╔╝ //╚═╝ ╚═╝░░╚═╝╚═╝░░░░░╚═╝ ╚═════╝░╚═╝░░╚═╝╚══════╝╚═════╝░╚═╝░░╚═╝╚══════╝░╚═════╝░╚═════╝░
• Oct 15, 2022 •CodeCatch
0 likes • 6 views
public static String addBinary(){ // The two input Strings, containing the binary representation of the two values: String input0 = "1010"; String input1 = "10"; // Use as radix 2 because it's binary int number0 = Integer.parseInt(input0, 2); int number1 = Integer.parseInt(input1, 2); int sum = number0 + number1; return Integer.toBinaryString(sum); //returns the answer as a binary value; }
public class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode head = new ListNode(0); ListNode handler = head; while(l1 != null && l2 != null) { if (l1.val <= l2.val) { handler.next = l1; l1 = l1.next; } else { handler.next = l2; l2 = l2.next; } handler = handler.next; } if (l1 != null) { handler.next = l1; } else if (l2 != null) { handler.next = l2; } return head.next; } }
• May 21, 2025 •AustinLeath
• Apr 15, 2025 •shivainsharma2124-fbae
public class Main { public static void main(String[] args) { System.out.println("Hello World"); } }