This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//print a 'subset' that sum to number nearest to k | |
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
int tracks[20]; | |
int n, k; | |
int ans; | |
int used[20], sz, ansSize, ansArr[20]; | |
bool found; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Calculate sum of all permutation of 12 numbers | |
satisfying a given constraint | |
*/ | |
#include <cstdio> | |
#define inf 1000000000 | |
#define mon 12 | |
#define csc 4 //consecutive | |
int s, d; | |
long long ans, maxSurplus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Precomputes all valid combinations and match | |
#include <bits/stdc++.h> | |
using namespace std; | |
#define N 8 | |
#define vi vector<int> | |
#define vvi vector<vi> | |
#define rdi(r,c) (r - c + N - 1) //right diag index Why N + 1 discuss wid akku | |
#define ldi(r,c) (r + c) //left diag index | |
bool row[8] = {0}, rd[30] = {0}, ld[30] = {0}; | |
vvi queens; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int n; | |
int num[16]; | |
int mask; | |
bool isprime(int x){ | |
if (x == 1) return false; | |
for (int i = 2; i * i <= x; ++i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define prev(n) n-1 | |
struct piece{ | |
int x, y; | |
piece(){} | |
piece(int a, int b):x(a), y(b){} | |
}; | |
int n, m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#include <bits/stdc++.h> | |
using namespace std; | |
// int rev(string &s){ | |
// int be = 0; | |
// int en = s.size(); | |
// int sp = 0; | |
// while(sp != string::npos && be < en){ | |
// sp = find() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class largestSubarray{ | |
public static void main(String[] args){ | |
Scanner s = new Scanner(System.in); | |
int n = s.nextInt(); | |
int sum = s.nextInt(); | |
int num[] = new int[n]; | |
for (int i = 0; i < n; ++i) | |
num[i] = s.nextInt(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class wordsRev{ | |
public static void main(String[] args){ | |
Scanner s = new Scanner(System.in); | |
String inp = s.nextLine(); | |
String rev = wordsReverse(inp); | |
System.out.println(rev); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class balParant{ | |
public static void main(String[] args){ | |
Scanner s = new Scanner(System.in); | |
String str = s.nextLine(); | |
System.out.println(check(str)); | |
} | |
public static boolean check(String s){ | |
char[] exp = s.toCharArray(); |
OlderNewer