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.io.File; | |
import java.io.FileNotFoundException; | |
import java.util.*; | |
public class SecretSanta { | |
public static void main(String[] args) { | |
File inputFile = new File("names.txt"); | |
List<String> names = readNamesFromFile(inputFile); | |
Map<String, String> secretSanta = generateSecretSanta(names); | |
printSecretSanta(secretSanta); |
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
batch_size = cnf.get_batch_size() | |
batch = [] | |
#Some code to fill the batch | |
if len(batch) == batch_size: | |
#Flush out the batch by saving to DB | |
else: | |
#Some other code | |
#The Fix here is not to forget to convert the config parameter to int | |
batch_size = int(cnf.get_batch_size()) |
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.Scanner; | |
public class Solution { | |
public static void main(String []args) { | |
Scanner reader = new Scanner(System.in); | |
String str1 = reader.nextLine(); | |
String str2 = reader.nextLine(); | |
if(hasEditDistance1(str1, str2)) | |
System.out.println("Yes"); | |
else |
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 <iostream> | |
#include <vector> | |
#include <cstdlib> | |
#include <set> | |
using namespace std; | |
int main() { | |
int t; | |
cin >> t; |
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 <iostream> | |
#include <vector> | |
#include <cstdlib> | |
using namespace std; | |
int main() { | |
int t; | |
cin >> t; | |
while(t--) { | |
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 <iostream> | |
using namespace std; | |
int path_length(int p, int q) { | |
int len = 0; | |
//Until p and q reach their lowest common ancestor. | |
while (p != q ) { | |
if( p > q ) { | |
p = p/2; | |
len++; |
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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int t; | |
cin >> t; | |
while( t-- ) { | |
int n; |
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 <iostream> | |
#include <vector> | |
using namespace std; | |
bool search_adj(const vector<int> &arr, int s) { | |
bool ret = false; | |
size_t i; | |
for( i = 0; i < arr.size(); ) { | |
if( arr[i] == s ) { |
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 <iostream> | |
#include <vector> | |
#include <climits> | |
#include <cstdlib> | |
using namespace std; | |
bool is_double(string &input) { | |
size_t len = input.size(); | |
if( len % 2 == 1 ) | |
return false; |
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 <iostream> | |
using namespace std; | |
int main() { | |
string input="12345"; | |
int len = input.size(); | |
int i,j; | |
for( i = 0; i < len; i++) | |
{ | |
for( j = 0; j < len; j++) |