Skip to content

Instantly share code, notes, and snippets.

View Cyberster's full-sized avatar
😎
A programmer guy with a soldering iron!

Arpan Das Cyberster

😎
A programmer guy with a soldering iron!
View GitHub Profile
public class Prime {
public boolean isPrime (int input1) {
if (1 == input1) return false;
for (int i = 2; i <= Math.sqrt(input1); i++) {
if (input1 % i == 0) {
//System.out.println("1");
return false;
}
}
@Cyberster
Cyberster / Combination.java
Last active January 27, 2019 16:53
Generates all possible combinations from given symbols
package com.w3epic;
import java.util.*;
public class Combination<T> {
// combinations = blank i.e. {} initially, currentLevel = 0 initially
/* getCombinations(String symbols, int parent, List<Integer> combinations, int currentLevel, int targetLevel)
* List<String> symbols: contains symbols like 1234 or abcd
* List<String> parent: parent node which will be combined with the symbols, initially 0
* List<List<String>> combinations: its the data to be passed while calling, it'll carry the result, initially blank ArrayList(Integer)
* int currentLevel: current level of tree i.e. current combination digit count, initially 0