Eat Study Love

먹고 공부하고 사랑하라

혼코딩 82

Minimum Index Sum of Two Lists[E,Array,Hash Table,String]

https://leetcode.com/problems/minimum-index-sum-of-two-lists/description/Given two arrays of strings list1 and list2, find the common strings with the least index sum.A common string is a string that appeared in both list1 and list2.A common string with the least index sum is a common string such that if it appeared at list1[i] and list2[j] then i + j should be the minimum value among all the ot..

Coding_Practice 2024.08.12

Range Sum of Sorted Subarray Sums[M,Array,Two Pointers,Binary Search,Sorting]

https://leetcode.com/problems/range-sum-of-sorted-subarray-sums/description/?envType=daily-question&envId=2024-08-04You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.Return the sum of the numbers from index left to i..

Coding_Practice 2024.08.05

Make Two Arrays Equal by Reversing Subarrays[E,Array,Hash Table,Sorting]

https://leetcode.com/problems/make-two-arrays-equal-by-reversing-subarrays/description/?envType=daily-question&envId=2024-08-03You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.Return true if you can make arr equal to target or false otherwise. Example 1:Input: tar..

카테고리 없음 2024.08.03

Linked List Loops(Python)

Linked list의 loop이 있는지 확인하는 건 1칸 씩 이동하는 slow와 2칸 씩 이동하는 Fast를 선언해서 T/F를 반환할 수 있었다고 알고 있었는데, 전체 list의 길이를 반환하는 거는 처음봤다. 일차적으로 내가 풀었을 땐 # Do not modify!class LinkedNode: def __init__(self, value): self.value = value self.next = None def hasLoop(head): if not head : return 0, True if not head.next : return 1,True slow = head fast = head.next cond = False while fast and f..

Coding_Practice 2024.08.02

Symmetric Tree[E,Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/symmetric-tree/description/Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1:Input: root = [1,2,2,3,4,4,3]Output: trueExample 2:Input: root = [1,2,2,null,3,null,3]Output: false Constraints:The number of nodes in the tree is in the range [1, 1000].-100  Follow up: Could you solve it both recursively..

Coding_Practice 2024.07.31

Maximum Level Sum of a Binary Tree[M,Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on.Return the smallest level x such that the sum of all the values of nodes at level x is maximal. Example 1:Input: root = [1,7,0,7,-8,null,null]Output: 2Explanation: Level 1 sum = 1.Level 2 sum = 7 + 0 = 7.Level 3 sum = 7 + -8 = -1...

Coding_Practice 2024.07.31