[LeetCode] Uncrossed Lines

1035. 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 draw does not intersect any other connecting (non-horizontal) line.

Note that a connecting line cannot intersect even at the endpoints (i.e., each number can only belong to one connecting line).

Return the maximum number of connecting lines we can draw in this way.

Read more
[LeetCode] Minimum ASCII Delete Sum for Two Strings

712. Minimum ASCII Delete Sum for Two Strings

Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.

Read more
[LeetCode] House Robber II

213. House Robber II

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and it will automatically contact the police if two adjacent houses were broken into on the same night.

Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

Read more
[LeetCode] Find Substring With Given Hash Value

2156. Find Substring With Given Hash Value

The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function:

  • hash(s, p, m) = (val(s[0]) p0 + val(s[1]) p1 + … + val(s[k-1]) * pk-1) mod m.
    Where val(s[i]) represents the index of s[i] in the alphabet from val(‘a’) = 1 to val(‘z’) = 26.

You are given a string s and the integers power, modulo, k, and hashValue. Return sub, the first substring of s of length k such that hash(sub, power, modulo) == hashValue.

The test cases will be generated such that an answer always exists.

A substring is a contiguous non-empty sequence of characters within a string.

Read more
[Google foobar] Level 3 Bomb, Baby!

Google foobar challenge level 3 - Bomb, Baby!

Read more
[Google foobar] Level 3 Fuel Injection Perfection

Google foobar challenge level 3 - Fuel Injection Perfection

Read more
[Google foobar] Level 3 Doomsday Fuel

Google foobar challenge level 3 - Doomsday Fuel

Read more
[Google foobar] Level 2 Ion Flux Relabeling

Google foobar challenge level 2 - Ion Flux Relabeling

Read more
[Google foobar] Level 2 Gearing Up for Destruction

Google foobar challenge level 2 - Gearing Up for Destruction

Read more
[Google foobar] Level 1 Minion Work Assignments

Google foobar challenge level 1 - Minion Work Assignments

Read more