Mojo πŸ”₯ Programming

Programming problems in mojo

View project on GitHub

πŸ” Code Examples

🟒 Game of life βž” Contains an implementation of Conway’s Game of Life cellular automation.

🟒 Two sum βž” Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

🟒 Three sum βž” Find all unique triplets [a, b, c] in the array such that a + b + c = 0.

🟒 Four sum βž” Find all unique quadrulets [a, b, c, d] in the array such that a + b + c + d = target.

🟒 Buy and Sell Stock 1 βž” Maximize profit by buying once and selling later on a future day.

🟒 Buy and Sell Stock 2 βž” Maximize profit by buying and selling multiple times.

🟒 Longest Substring Without Repeating Characters βž” Given a string s, find the length of the longest substring without duplicate characters.

🟒 Product of Array Except Self βž” Return an array where each element is the product of all others in the input array.

🟒 Maximum Subarray βž” Given an integer array nums, find the subarray with the largest sum, and return its sum.

🟒 Maximum Average Subarray βž” Find the maximum average of any contiguous subarray of length k from the array.

🟒 Maximum Product Subarray βž” Find the maximum product of a contiguous subarray.

🟒 Minimum in Rotated Sorted Array βž” Given a sorted and rotated array, find the minimum element.

🟒 Search in Rotated Sorted Array βž” Find item index in sorted rotated array of items.

🟒 Find custom struct index βž” πŸ” Binary Search for Rectangle (a Shape) in a Rotated Sorted List.

🟒 Search in Rotated sorted Array 2 βž” πŸ” Search in a rotated sorted array that may contain duplicates.

🟒 Convert String to Signed Integer βž” Implement the atoi(string s) function, which converts a string to a 64-bit signed integer.

🟒 Remove Duplicate βž” Remove duplicates from sorted array.

🟒 Merge Sorted Array In Place βž” A has extra space to hold B. Merge B into A as one sorted array.

🟒 Container With Most Water βž” Given an array of line heights, find the two lines that form the container holding the most water.

🟒 Count 1s βž” Count the number of set bits (Hamming weight) in the binary representation of a positive integer n.

🟒 Count 1s For Each Entry βž” Return an array where each element at index i (0 ≀ i ≀ n) is the number of 1’s in the binary representation of i.

🟒 Generic singnly link list βž” A singly linked list with parametric polymorphism.

🟒 Combination sum βž” Find all unique combinations of numbers from candidates (reusable unlimited times) that sum to target.

🟒 Word Search βž” Check if a word can be formed in a grid by sequentially adjacent (non-repeating) horizontal or vertical letters.

🟒 Longest Common Subsequence Recursive βž” Return the length of the longest common subsequence between two strings, or 0 if none exists

🟒 Longest Common Subsequence Dynamic βž” Return the length of the longest common subsequence between two strings, or 0 if none exists

🟒 Longest Palindromic Substring βž” Given a string s, return the longest palindromic substring therein

🟒 Interleaving String βž” Determine if s3 is an interleaving of s1 and s2.

🟒 Check device core βž” Check physical and logical cores of the device

🟒 SIMD Select βž” Select based on a SIMD (Single Instruction, Multiple Data) mask

🟒 Last word length βž” Return the length of the last word in a given space-separated string

🟒 Largest Number βž” Arrange non-negative integers to form the largest possible number and return it as a string.

🟒 Find All Anagrams in a String βž” Return all start indices of anagrams of stringβ€―pβ€―in stringβ€―s.

🟒 Find First/Last βž” Find first and last index of a target value in a sorted array

🟒 Merge Itervals βž” Merge overlapping intervals