Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
class Solution:
def alternatingSubarray(self, nums: List[int]) -> int:
# Combination search O(n^2).
max_length = -1
for i in range(len(nums) - 1):
cur_length = 0
is_odd = True
# Check the subarray of values from i to the end of the array.
@primaryobjects
primaryobjects / index.html
Last active December 10, 2023 03:22
FDIC Bank Failures by Year in Python using Flask, pandas, requests, sqlite3 https://pandas-numpy-practice.primaryobjects.repl.co
<!DOCTYPE html>
<html>
<head>
<title>Bank Failures by Year</title>
<!-- Include Bulma CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
</head>
<body>
<section class="section">
<div class="container">
@primaryobjects
primaryobjects / ff2-auto-key.au3
Last active December 3, 2023 19:39
AutoIt script to automatically level up a magic spell in Final Fantay II on PSX (PS1) in the psxfin emulator.
;
; AutoIt script to automatically level up a magic spell in Final Fantay II on PSX (PS1).
;
#include <Constants.au3>
Opt("SendKeyDownDelay", 20)
$count = 10
; Wait for the window to become active.
If WinActivate("pSX v1.13") Then
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} original
* @param {TreeNode} cloned
public class Solution {
public int MinOperations(string s) {
// Using original first bit.
int count1 = 0;
char prev1 = s[0];
// Using opposite first bit.
int count2 = 1;
char prev2 = prev1 == '0' ? '1' : '0';
for (int i=1; i<s.Length; i++)
@primaryobjects
primaryobjects / order.cs
Created October 30, 2023 01:20
Print in order using locks and semaphore, multithreaded, threads in C# https://leetcode.com/problems/print-in-order
using System.Threading;
public class Foo {
private static Object _lock = new Object();
private static int _sequence = 0;
private int _limit = 100;
public Foo() {
}
public class Solution {
public int MinTimeToVisitAllPoints(int[][] points) {
int seconds = 0;
int cx = points[0][0];
int cy = points[0][1];
for (int i=1; i<points.Length; i++)
{
int[] coord = points[i];
int x = coord[0];
@primaryobjects
primaryobjects / hotspot-keepalive.bat
Last active May 14, 2026 03:42
Script to Enable Windows 10 Wifi Mobile Hotspot Automatically and Keep Alive on Disconnect
PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1
PowerShell C:\Users\YOUR_USERNAME\Desktop\hotspot-keepalive.ps1 >> "%TEMP%\StartupLog.txt" 2>&1
public class MinStack {
private struct Item
{
public int Val;
public int ParentMin;
};
private int _min;
private List<Item> _stack;
private int _minIndex;
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body onload="countRefreshes()">
<div class="container mt-5">
<div class="card">