Skip to content

Instantly share code, notes, and snippets.

View chermehdi's full-sized avatar
💭
My opinions are my own.

Mehdi Cheracher chermehdi

💭
My opinions are my own.
View GitHub Profile
public V put(K key, V value) {
return putVal(hash(key), key, value, false, true);
}
/**
* Implements Map.put and related methods
*
* @param hash hash for key
* @param key the key
* @param value the value to put
public V put(K key, V value) {
int Hash = hash(key.hashCode());
//use the Hash as a mask
int ind = (Hash & (n - 1));
//put if the ind is bigger then the internal table resize()
table[ind] = new Node(hash, key, value);
}
public V get(Object key) {
Node<K,V> e;
return (e = getNode(hash(key), key)) == null ? null : e.value;
}
/**
* Implements Map.get and related methods
*
* @param hash hash for key
* @param key the key
public V get(Object key){
int Hash = hash(key.hashcode());
int ind = (Hash & (n - 1));
return table[ind]; // the value at the calculated index
}
#include <stdio.h>
#include <string.h>
int t, n;
int isInt(char a){return a >= '0' && a <= '9';}
typedef struct card{
int n, type;
}card;
card Card(char a[2]) {
card r;
#include <stdio.h>
#include <string.h>
#define clr(a,b) memset((a), (b), sizeof((a)))
/**
*
* @Author Mehdi Maick
*/
int n, t, k;
t = int(input())
for i in range(t):
n = int(input())
votes = [0]*(n + 1)
mi = 0
for j in range(n):
votes[j] = int(input())
if votes[j] > votes[mi]:
mi = j
s = sum(votes)
@chermehdi
chermehdi / a.c
Created January 1, 2017 07:52
scorify MCPC QUICK CHALLANGE 2 - Problem A
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc , char* argv[]) {
int t, tc = 1, a, b, ans;
char op;
char name[20], res[20];
scanf("%d",&t);
@chermehdi
chermehdi / WatchServiceDemo.java
Created January 1, 2017 13:02
A watch Service Demonstration
import java.io.IOException;
import java.nio.file.*;
import java.util.concurrent.TimeUnit;
/**
* Created by mac on 01/01/2017.
*/
public class WatchServiceDemo {
@chermehdi
chermehdi / 44.cc
Created January 26, 2017 18:12
euler #44
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
long long p(long long n){
return n * (3*n - 1)/2;