Solved! Leetcode 1091. Shortest Path in Binary Matrix

source: https://leetcode.com/problems/shortest-path-in-binary-matrix/description/ Shortest Path in Binary Matrix Table of ContentsShortest Path in Binary MatrixDescriptionExample 1:Example 2:Example 3:Constraints:Solution Description Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1. A clear path in a binary matrix is a path ...

Solved! Leetcode 2101. Detonate the Maximum Bombs

Table of ContentsDetonate the Maximum BombsExample 1:Example 2:Example 3:Constraints:Solution source: https://leetcode.com/problems/detonate-the-maximum-bombs/ Detonate the Maximum Bombs You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the ...

Solved! Leetcode 785. Is Graph Bipartite?

source: https://leetcode.com/problems/is-graph-bipartite/description/ Is Graph Bipartite? There is an undirected graph with n nodes, where each node is numbered between 0 and n – 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected ...

Solved! Leetcode 703. Kth Largest Element in a Stream

source: https://leetcode.com/problems/kth-largest-element-in-a-stream/description/ Kth Largest Element in a Stream Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest class: KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of ...

Solved! Leetcode 253. Meeting Rooms II

source: https://leetcode.com/problems/meeting-rooms-ii/description/ Meeting Rooms II Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required. Example 1: Input: intervals = [[0,30],[5,10],[15,20]] Output: 2 Example 2: Input: intervals = [[7,10],[2,4]] Output: 1 Constraints: 1 <= intervals.length <= 104 0 <= starti < endi <= 106 ...

Solved! Leetcode 347. Top K Frequent Elements

source: https://leetcode.com/problems/top-k-frequent-elements/description/ Top K Frequent Elements Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Constraints: 1 <= nums.length ...

Solved! Leetcode 1035. Uncrossed Lines

source: https://leetcode.com/problems/uncrossed-lines/description/ Uncrossed Lines You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that: nums1[i] == nums2[j], and the line we ...

Solved! Leetcode 2466. Count Ways To Build Good Strings

source: https://leetcode.com/problems/count-ways-to-build-good-strings/description/ Count Ways To Build Good Strings Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following: Append the character ‘0’ zero times. Append the character ‘1’ one times. This can be performed any number ...

Solved! Leetcode 2130. Maximum Twin Sum of a Linked List

source: https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/description/ Maximum Twin Sum of a Linked List In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) – 1. For example, if n = 4, then node ...

Solved Leetcode 1721: Swapping Nodes in a Linked List

source: https://leetcode.com/problems/swapping-nodes-in-a-linked-list/description/ Swapping Nodes in a Linked List You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed). Example 1: Input: head = ...