Skip to content

Instantly share code, notes, and snippets.

@ayreact
ayreact / Day 13.md
Created January 21, 2026 22:46
3Sum

3Sum

Problem

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

Solution

class Solution(object):
    def threeSum(self, nums):
        """

Longest Common Prefix

Problem

Write a function to find the longest common prefix string amongst an array of strings.

Solution

class Solution(object):
    def longestCommonPrefix(self, strs):
 """
@ayreact
ayreact / Day 11.md
Created January 15, 2026 22:58
Roman to Integer

Roman to Integer

Problem

Given a roman numeral, convert it to an integer.

Solution

class Solution(object):
    def romanToInt(self, s):
 """
@ayreact
ayreact / Day 10.md
Created January 14, 2026 21:13
Integer to Roman

Integer to Roman

Problem

Given an integer, convert it to a Roman numeral.

Solution

class Solution(object):
    def intToRoman(self, num):
 """
@ayreact
ayreact / Day 9.md
Created January 11, 2026 10:32
Container With Most Water

Container With Most Water

Problem

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

Find two lines that together with the x-axis form a container, such that the container contains the most water.

Return the maximum amount of water a container can store.

Notice that you may not slant the container.

@ayreact
ayreact / Day 8.md
Created January 10, 2026 22:24
Regular Expression Matching

Regular Expression Matching

Problem

Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:

  • '.' Matches any single character.
  • '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial).

Solution

Palindrome Number

Problem

Given an integer x, return true if x is a palindrome, and false otherwise.

Solution

class Solution(object):
    def isPalindrome(self, x):
 """

Palindrome Number

Problem

Given an integer x, return true if x is a palindrome, and false otherwise.

Solution

class Solution(object):
    def isPalindrome(self, x):
 """

String to Integer(atoi)

Problem Description

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer.

The algorithm for myAtoi(string s) is as follows:

  • Whitespace: Ignore any leading whitespace (" ").
  • Signedness: Determine the sign by checking if the next character is '-' or '+', assuming positivity if neither present.
  • Conversion: Read the integer by skipping leading zeros until a non-digit character is encountered or the end of the string is reached. If no digits were read, then the result is 0.
@ayreact
ayreact / Day 5.md
Created January 7, 2026 19:12
Reverse Integer

Reverse Integer

Problem

Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.

Solution

class Solution(object):
    def is_32_bit_signed(self, num):
 l_limit = -2**31