MCPcopy Create free account

hub / github.com/austingebauer/go-leetcode / functions

Functions430 in github.com/austingebauer/go-leetcode

↓ 1 callersFunctionexplore
(arr []string, index int, usedChar int)
maximum_length_of_a_concatenated_string_with_unique_characters_1239/solution.go:11
↓ 1 callersFunctionexplore3
This approach is better (O(n^2)) runtime. It is accepted by leetcode. It's not exactly simple though and the intuition for the memoization is a bit co
longest_increasing_subsequence_300/solution.go:60
↓ 1 callersFunctionexploreIsland
(grid [][]byte, r int, c int)
number_of_islands_200/solution.go:18
↓ 1 callersFunctionexploreStairs
(n int, c int, memo []int)
climbing_stairs_70/solution.go:8
↓ 1 callersFunctionfib
(N int)
fibonacci_number_509/solution.go:3
↓ 1 callersFunctionfill
(subsets []int, idx int, nums []int, target int)
partition_to_k_equal_sum_subsets_698/solution.go:37
↓ 1 callersFunctionfindDifference
(nums1 []int, nums2 []int)
find_the_difference_of_two_arrays_2215/solution.go:3
↓ 1 callersFunctionfindIndex
(inorder []int, val int)
construct_binary_tree_from_preorder_and_inorder_traversal_105/solution.go:19
↓ 1 callersFunctionfindMaxAverage
(nums []int, k int)
maximum_average_subarray_i_643/solution.go:5
↓ 1 callersFunctionfindMin
Time: O(log(n)) Space: O(1)
find_minimum_in_rotated_sorted_array_153/solution.go:5
↓ 1 callersFunctionfindMinLinear
Time: O(n) Space: O(1)
find_minimum_in_rotated_sorted_array_153/solution.go:61
↓ 1 callersFunctionfindPivot
(nums []int)
search_in_rotated_sorted_array_33/solution.go:109
↓ 1 callersFunctionfirstUniqChar
(s string)
first_unique_character_in_a_string_387/solution.go:5
↓ 1 callersFunctionfizzBuzz
(n int)
fizz_buzz_412/solution.go:5
↓ 1 callersFunctionfreqAlphabets
(s string)
decrypt_string_from_alphabet_to_integer_mapping_1309/solution.go:5
↓ 1 callersFunctiongameOfLife
(board [][]int)
game_of_life_289/solution.go:3
↓ 1 callersFunctiongenP
(strs []string, n int, s string)
generate_parentheses_22/solution.go:7
↓ 1 callersFunctiongenerate
(numRows int)
pascals_triangle_118/solution.go:3
↓ 1 callersFunctiongenerateParenthesis
(n int)
generate_parentheses_22/solution.go:3
↓ 1 callersFunctiongetIntersectionNode
** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */
intersection_of_two_linked_lists_160/solution.go:16
↓ 1 callersFunctiongetLiveNeighbors
(board [][]int, r, c, rows, cols int)
game_of_life_289/solution.go:31
↓ 1 callersFunctiongetNoZeroIntegers
(n int)
convert_integer_to_the_sum_of_two_no_zero_integers/solution.go:3
↓ 1 callersFunctiongetSum
Note: study again. Cool problem!
sum_of_two_integers_371/solution.go:4
↓ 1 callersFunctiongetWinner
(board []string)
valid_tic_tac_toe_state_794/solution.go:49
↓ 1 callersFunctiongroupAnagrams
Third solution based on creating identical encoding for strings that are anagrams of each other for grouping.
group_anagrams_49/solution.go:12
↓ 1 callersFunctionhammingWeight
(num uint32)
number_of_1_bits_191/solution.go:3
↓ 1 callersFunctionhasCycleBFS
(adjList map[int][]int, zeroInQueue []int, inDegrees []int, numVerticies int)
course_schedule_207/solution.go:35
↓ 1 callersFunctionhasCycleDFS
(adjList map[int][]int, colors []int, course int)
course_schedule_207/solution.go:85
↓ 1 callersFunctioninOrderTraverse
(root *TreeNode, k int)
kth_smallest_element_in_a_bst_230/solution.go:13
↓ 1 callersFunctioninorderSuccessor
** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */
inorder_successor_in_bst_285/solution.go:15
↓ 1 callersFunctioninorderTraversal
(root *TreeNode)
validate_binary_search_tree_98/solution.go:20
↓ 1 callersFunctioninorderTraverse
(root *TreeNode, a []int)
symmetric_tree_101/solution.go:57
↓ 1 callersFunctioninsert
Note: cool hard problem :)
insert_interval_57/solution.go:8
↓ 1 callersFunctionintersect
(nums1 []int, nums2 []int)
intersection_of_two_arrays_ii_350/solution.go:3
↓ 1 callersFunctioninvertTree
(root *TreeNode)
invert_binary_tree_226/solution.go:5
↓ 1 callersFunctionisAlienSorted
(words []string, order string)
verifying_an_alien_dictionary_953/solution.go:3
↓ 1 callersFunctionisAnagram
(s string, t string)
valid_anagram_242/solution.go:3
↓ 1 callersFunctionisAnagram
(s1, s2 string)
group_anagrams_49/solution.go:94
↓ 1 callersFunctionisAnagram0
(s string, t string)
valid_anagram_242/solution.go:32
↓ 1 callersFunctionisHappy
(n int)
happy_number_202/solution.go:5
↓ 1 callersFunctionisPalindrome
(x int)
palindrome_number_9/solution.go:5
↓ 1 callersFunctionisPalindrome
** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } * * O(n^2) rt and O(1) space. */
palindrome_linked_list_234/solution.go:16
↓ 1 callersFunctionisPalindrome
(s string)
valid_palindrome_125/solution.go:8
↓ 1 callersFunctionisSameTree
(p *TreeNode, q *TreeNode)
same_tree_100/solution.go:5
↓ 1 callersFunctionisSubtree
** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */
subtree_of_another_tree_572/solution.go:15
↓ 1 callersFunctionisSym
(left, right *TreeNode)
symmetric_tree_101/solution.go:22
↓ 1 callersFunctionisSymmetric
** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ Note: good pro
symmetric_tree_101/solution.go:18
↓ 1 callersFunctionisValid
(s string)
valid_parentheses_20/solution.go:3
↓ 1 callersFunctionisValidBST
(root *TreeNode)
validate_binary_search_tree_98/solution.go:5
↓ 1 callersFunctionkthSmallest
(root *TreeNode, k int)
kth_smallest_element_in_a_bst_230/solution.go:8
↓ 1 callersFunctionlargestAltitude
-4 -3 -2 -1 4 3 2 ^ -4 -7 -9 -10 -6 -3 -1
find_the_highest_altitude_1732/solution.go:10
↓ 1 callersFunctionlcs
(text1, text2 string, text1Idx, text2Idx int, memo [][]int)
longest_common_subsequence_1143/solution.go:45
↓ 1 callersFunctionlengthOfLIS
Note: study again. Good dp problem.
longest_increasing_subsequence_300/solution.go:6
↓ 1 callersFunctionlengthOfLongestSubstring
(s string)
longest_substring_without_repeating_characters_3/solution.go:5
↓ 1 callersFunctionletterCombinations
(digits string)
letter_combinations_of_a_phone_number_17/solution.go:3
↓ 1 callersFunctionlevelOrder
Slight variation of first correct solution below, which doesn't keep counters for the number of elements in a level. It just uses the current, constan
binary_tree_level_order_traversal_102/solution.go:9
↓ 1 callersFunctionlongestCommonPrefix
(strs []string)
longest_common_prefix_14/solution.go:3
↓ 1 callersFunctionlongestCommonSubsequence
Note: study again. DP bottoms-up solution. Builds on same idea of recursive solution but starts from adding to subsequences from front-to-back. Starti
longest_common_subsequence_1143/solution.go:9
↓ 1 callersFunctionlongestCommonSubsequence2
Note: recursive top-down solution with memoization built on top of it.
longest_common_subsequence_1143/solution.go:31
↓ 1 callersFunctionlongestConsecutive
(nums []int)
longest_consecutive_sequence_128/solution.go:3
↓ 1 callersFunctionlongestPalindrome
expand at the center 2*n - 1 times for palindromes with even and odd lengths
longest_palindromic_substring_5/solution.go:7
↓ 1 callersFunctionlongestPalindrome0
Note: study again
longest_palindromic_substring_5/solution.go:52
↓ 1 callersFunctionlowestCommonAncestor
(root, p, q *TreeNode)
lowest_common_ancestor_of_a_binary_search_tree_235/solution.go:5
↓ 1 callersFunctionmajorityElement
Note: study again
majority_element_ii_229/solution.go:4
↓ 1 callersFunctionmajorityElement
Note: https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm Good problem and intro to a new algorithm.
majority_element_169/solution.go:5
↓ 1 callersFunctionmapValuesLessThanOne
(m map[string]int)
minimum_window_substring_76/solution.go:46
↓ 1 callersFunctionmaxArea
(height []int)
container_with_most_water_11/solution.go:5
↓ 1 callersFunctionmaxDepth
(root *TreeNode)
maximum_depth_of_binary_tree_104/solution.go:8
↓ 1 callersFunctionmaxLength
Note: Study again. Good problem with bit manipulation to detect if a string has unique characters.
maximum_length_of_a_concatenated_string_with_unique_characters_1239/solution.go:7
↓ 1 callersFunctionmaxPathSum
(root *TreeNode)
binary_tree_maximum_path_sum_124/solution.go:10
↓ 1 callersFunctionmaxPathSumHelper
(root *TreeNode)
binary_tree_maximum_path_sum_124/solution.go:16
↓ 1 callersFunctionmaxProduct
Note: study again. Time: O(n), Space: O(1)
maximum_product_subarray_152/solution.go:7
↓ 1 callersFunctionmaxProfit
Keep on adding the difference between the consecutive numbers of the slice, if the second number is larger than the first one (profit). The image in t
best_time_to_buy_and_sell_stock_ii_122/solution.go:10
↓ 1 callersFunctionmaxProfit
O(n^2) time and O(1) space
best_time_to_buy_and_sell_stock_121/solution.go:32
↓ 1 callersFunctionmaxProfit2
O(n) time and O(1) space
best_time_to_buy_and_sell_stock_121/solution.go:17
↓ 1 callersFunctionmaxProfit3
O(n) time and O(1) space
best_time_to_buy_and_sell_stock_121/solution.go:6
↓ 1 callersFunctionmaxSubArray
Note: study again Kadane's Algorithm works for this problem https://www.youtube.com/watch?v=86CQq3pKSUw Remembering past sums (dynamic programming) re
maximum_subarray_53/solution.go:9
↓ 1 callersFunctionmaxSubArray2
Solved for the 2nd time
maximum_subarray_53/solution.go:22
↓ 1 callersFunctionmerge
Second solution
merge_intervals_56/solution.go:9
↓ 1 callersFunctionmerge
O(m+n) solution
merge_sorted_array_88/solution.go:4
↓ 1 callersFunctionmergeAlternately
(word1 string, word2 string)
merge_strings_alternately_1768/solution.go:3
↓ 1 callersFunctionmergeKLists
(lists []*ListNode)
merge_k_sorted_lists_23/solution.go:61
↓ 1 callersFunctionmergeKListsDivideAndConquer
** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ My first solution to divide and conqu
merge_k_sorted_lists_23/solution.go:14
↓ 1 callersFunctionmergeKListsDivideAndConquerClever
Clever solution to divide and conquer found on leetcode. Debugged to understand more.
merge_k_sorted_lists_23/solution.go:44
↓ 1 callersFunctionmergeTwoLists0
(l1 *ListNode, l2 *ListNode)
merge_two_sorted_lists_21/solution.go:73
↓ 1 callersFunctionmergeTwoLists2
(l1 *ListNode, l2 *ListNode)
merge_two_sorted_lists_21/solution.go:5
↓ 1 callersFunctionminChange
(coins []int, rem int, memo []int)
coin_change_322/solution.go:79
↓ 1 callersFunctionminMeetingRooms
First time around was more elegant, although, I didn't solve it without help the first time. I solved this again, reasoning alone, and came up with so
meeting_rooms_ii_253/solution.go:12
↓ 1 callersFunctionminMeetingRooms0
Note: Study again. Really good problem!
meeting_rooms_ii_253/solution.go:62
↓ 1 callersFunctionminWindow
Second solution. Intuition is to open the window until character frequencies in t are all less than zero. After, close the window until any single cha
minimum_window_substring_76/solution.go:7
↓ 1 callersFunctionmissingNumber
(nums []int)
missing_number_268/solution.go:3
↓ 1 callersFunctionmoveZeroes
Ex: [1,0,0,3,12] i p
move_zeroes_283/solution.go:7
↓ 1 callersFunctionnumIslands
(grid [][]byte)
number_of_islands_200/solution.go:3
↓ 1 callersFunctionnumSmallerByFrequency
Note: study again. A good problem for runtime optimization and memory trade-offs. By taking memory, we can speed up runtime of the algorithm.
compare_strings_by_frequency_of_the_smallest_character_1170/solution.go:7
↓ 1 callersFunctionoverlaps
(intervals [][]int)
non_overlapping_intervals_435/solution.go:74
↓ 1 callersFunctionpacificAtlantic
Second solution: From all locations where water flows in (pacific and atlantic coasts), see how far the water would flow in the land and mark those lo
pacific_atlantic_water_flow_417/solution.go:9
↓ 1 callersFunctionpacificAtlantic0
Initial solution: for each coordinate, see if you can reach both the pacific and the atlantic. Correct solution, but is slow.
pacific_atlantic_water_flow_417/solution.go:71
↓ 1 callersFunctionplusOne
(digits []int)
plus_one_66/solution.go:3
↓ 1 callersFunctionproductExceptSelf
Uses prefix and suffix products to calculate the answer.
product_of_array_except_self_238/solution.go:4
↓ 1 callersFunctionremoveDuplicates
(nums []int)
remove_duplicates_from_sorted_array_26/solution.go:3
← previousnext →101–200 of 430, ranked by callers