This file contains hidden or 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
""" | |
You are climbing a staircase. It takes `n` steps to reach the top. | |
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? | |
""" | |
from functools import lru_cache | |
@lru_cache |
This file contains hidden or 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
""" | |
Given an integer array nums, return the length of the longest strictly | |
increasing subsequence. | |
A subsequence is a sequence that can be derived from an array by deleting some | |
or no elements without changing the order of the remaining elements. For | |
example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7]. | |
""" | |
from typing import List |
This file contains hidden or 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
#!/usr/bin/env python3 | |
""" | |
Problem statement: | |
- https://composingprograms.com/pages/17-recursive-functions.html#example-partitions | |
- https://youtu.be/ngCos392W4w?t=678 | |
""" | |
from functools import lru_cache |
This file contains hidden or 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 <stdio.h> | |
#include <stdlib.h> | |
void swap(int *a, int *b); | |
void insert(int *subseq, int subseq_len); | |
void print_array(int *arr, int len_arr); | |
int main(void) | |
{ | |
int items[] = { |
This file contains hidden or 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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int * merge_sort(int *parr, int arr_len); | |
void print_array(int *arr, int len_arr); | |
int main(void) | |
{ |
This file contains hidden or 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 <stdio.h> | |
#include <stdlib.h> | |
int binary_search(const int *arr, const int arr_len, const int n); | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2) | |
{ |
This file contains hidden or 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 <stdio.h> | |
void swap(int *a, int *b); | |
void print_array(int *arr, int len_arr); | |
int main(void) | |
{ | |
int items[] = { 5, 2, 7, 4, 1, 6, 3, 0 }; |
This file contains hidden or 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 <stdio.h> | |
void swap(int *a, int *b); | |
void print_array(int *arr, int len_arr); | |
int main(void) | |
{ | |
int items[] = { 5, 2, 7, 4, 1, 6, 3, 0 }; |
This file contains hidden or 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 <stdio.h> | |
#include <string.h> | |
/* | |
* Extra credit: If an array of characters is 4 bytes long, and an integer is 4 | |
* bytes long, then can you treat the whole in_name array like it’s just an | |
* integer? | |
*/ | |
This file contains hidden or 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
""" | |
Recurse Center Programming Task: Tic-Tac-Toe | |
Author: Ravi Dayabhai | |
""" | |
from __future__ import annotations | |
import copy | |
import math | |
import os |