Skip to content

Instantly share code, notes, and snippets.

View ympons's full-sized avatar
🚀
-> 🆓| 🇨🇺| 👨‍💻

Yaismel Miranda ympons

🚀
-> 🆓| 🇨🇺| 👨‍💻
View GitHub Profile
@ympons
ympons / max_subarray.c
Created August 3, 2016 04:57
Find Max SubArray with given sum
#include <stdio.h>
int maxLength(int a_size, int* a, int k) {
int sum = a[0], i, ini=0, sol=0, s;
for (i=1;i<a_size;i++) {
sum += a[i];
while(sum > k && ini < i) {
sum -= a[ini];
ini++;
}
@ympons
ympons / palindrome_char.c
Created August 2, 2016 21:09
Check if the bits in a char are a palindrome
#include <stdio.h>
#include <limits.h>
int isPalind(char c) {
int a[CHAR_BIT];
for(int i=0;i<CHAR_BIT;i++) {
a[i] = (c >> i) & 1;
}
for (int i=0;i<5;i++) {
if (a[i] != a[7-i]) {
@ympons
ympons / recursive_reverse.go
Created March 14, 2016 03:07
Reverse Single Linked List
//@ympons - https://play.golang.org/p/mNEabcyTVa
package main
import "fmt"
type Node struct {
data int
next *Node
}
@ympons
ympons / reverse.go
Last active March 8, 2016 06:06
Reverse Linked List
//@ympons
// Reverse Linked List
package main
import "fmt"
type Node struct {
value int
next *Node
}
@ympons
ympons / rust-brainfuck.rs
Created September 23, 2015 06:46
Rust-Brainfuck implementation!!
//@ympons
trait Runnable {
fn run(&mut self);
}
struct Engine {
source: Vec<char>,
ip: usize,
tape: Vec<u8>,
p: usize,