Skip to content

Instantly share code, notes, and snippets.

View scaffeinate's full-sized avatar

Sudharsanan Muralidharan scaffeinate

View GitHub Profile
import java.util.HashMap;
import java.util.Map;
/**
* Created by sudharti on 10/30/17.
*/
public class BudgetShopping {
static int budgetShopping(int n, int[] bundleQuantities, int[] bundleCosts) {
return budgetShopping(n, bundleQuantities, bundleCosts, new HashMap<>());
}
@scaffeinate
scaffeinate / TicTacToeGame.java
Last active December 26, 2017 01:47
Two player Tic-Tac-Toe implementation in Java
package matrix;
import java.util.Arrays;
import java.util.Scanner;
/**
* TicTacToeGame
*/
public class TicTacToeGame {
def findSchedules(workHours, dayHours, pattern):
totalHours = 0
result = []
for c in pattern:
if c != '?':
totalHours = totalHours + int(c)
diff = workHours - totalHours
constructResult(list(pattern), 0, diff, dayHours, result)
return result
public static SinglyLinkedListNode removeNodes(SinglyLinkedListNode listHead, int x) {
SinglyLinkedListNode head = null, tail = null;
while (listHead != null) {
if (listHead.data <= x) {
SinglyLinkedListNode node = new SinglyLinkedListNode();
node.data = listHead.data;
if(head == null) {
head = tail = node;
} else {
tail.next = node;
public static int isPrime(int x) {
if(x <= 2) return 1;
int num = 2, k = 0, sqrt = (int) Math.sqrt(x);
boolean[] arr = new boolean[x-1];
while(num <= sqrt) {
if(arr[num-2]) {
num++;
continue;
}