[LeetCode] Number Of Corner Rectangles

750. Number Of Corner Rectangles

Given an m x n integer matrix grid where each entry is only 0 or 1, return the number of corner rectangles.

A corner rectangle is four distinct 1’s on the grid that forms an axis-aligned rectangle. Note that only the corners need to have the value 1. Also, all four 1’s used must be distinct.

Read more
[LeetCode] Find the Town Judge

997. Find the Town Judge

In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge.

If the town judge exists, then:

  1. The town judge trusts nobody.
  2. Everybody (except for the town judge) trusts the town judge.
  3. There is exactly one person that satisfies properties 1 and 2.

You are given an array trust where trust[i] = [ai, bi] representing that the person labeled ai trusts the person labeled bi.

Return the label of the town judge if the town judge exists and can be identified, or return -1 otherwise.

Read more
[LeetCode] Check If a Number Is Majority Element in a Sorted Array

1150. Check If a Number Is Majority Element in a Sorted Array

Given an integer array nums sorted in non-decreasing order and an integer target, return true if target is a majority element, or false otherwise.

A majority element in an array nums is an element that appears more than nums.length / 2 times in the array.

Read more
[LeetCode] Valid Palindrome II

680. Valid Palindrome II

Given a string s, return true if the s can be palindrome after deleting at most one character from it.

Read more
[Code Jam 2022 Qualification Round 2022] 3D PrintingRead more
[Code Jam 2022 Qualification Round 2022] d1000000Read more
[Code Jam 2022 Qualification Round 2022] Punched CardsRead more
[Code Jam 2022 Qualification Round 2022] Chain ReactionsRead more
[LeetCode] Maximum Gap

164. Maximum Gap

Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0.

You must write an algorithm that runs in linear time and uses linear extra space.

Read more
[LeetCode] Permutation Sequence

60. Permutation Sequence

The set [1, 2, 3, …, n] contains a total of n! unique permutations.

By listing and labeling all of the permutations in order, we get the following sequence for n = 3:

  1. “123”
  2. “132”
  3. “213”
  4. “231”
  5. “312”
  6. “321”

Given n and k, return the kth permutation sequence.

Read more