Practice (Intermediate)

back to index  |  new

Show that $2013^2 +2013^2\times 2014^2 + 2014^2$ is a perfect sqare.


Compute $\sqrt[32]{259\times 23\times 11 +9}$.


Let $f(x)$ be a second degree function satisfying $f(-2)=0$ and $2x \lt f(x) \le\frac{x^2+4}{2}$. Find the value of $f(10)$.


Let $a$, $b$, $c$, $x$, $y$, and $z$ be positive numbers. Show that $$\sqrt{a^2+x^2} + \sqrt{b^2 + y^2}+\sqrt{c^2+z^2} \ge \sqrt{(a+b+c)^2 + (x+y+z)^2}$$


Let positive numbers $a$, $b$ and $c$ satisfy $a+b+c=8$. Find the minimal value of $\sqrt{a^2+1}+\sqrt{b^2+4}+\sqrt{c^2+9}$.


Solve $x^{x^{88}} - 88=0$.


Given a pointer pointing to the header of a linked list, how to detect whether the linked list has a loop?

An additional question: how can math knowledge help here?


Show that there exists a perfect sqaure whose leading $2024$ digits are all $1$.


For any given integer $N$, show that there exists a perfect square whose leading digits match $N$. For example, if $N=2024$, there must exist a perfect square whose leading four digits are $2024$.


Given an string as input, find the length of the longest palindrome it contains. A palindrome is a word which stays the same if reading backwards. Examples include madam, Hannah. 


Determine whether a given integer can be expressed as the sum of two perfect squares.


(Coin Change Problem) Given a set of $N$ possible denominations of coins, find the number of different combinations to pay for a desired sum.


You are given an integer array height of length $n$. There are $n$ vertical lines drawn such that the two endpoints of the $i$th line are $(i, 0)$ and ($i$, height[$i$]). Find two lines that together with the $x$-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store.

Input: height = $[1,8,6,2,5,4,8,3,7]$

Output: $49$

Explanation: The above vertical lines are represented by array $[1,8,6,2,5,4,8,3,7]$. In this case, the max area of water (blue section) the container can contain is $49$.


Design an algorithm that finds the number of ways in which you can traverse $N$ meters by doing jumps of $1$, $2$, $3$, $4$, or $5$ meter lengths.


On a $M\times N$ board, some cells are occupied. Find the size of the largest square of unoccupied cells. 


Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. (Note that after backspacing an empty text, the text will continue empty.)

Example 1:

Input: s = "ab#c", t = "ad#c"

Output: true

Explanation: Both s and t become "ac".

Example 2:

Input: s = "ab##", t = "c#d#"

Output: true

Explanation: Both s and t become "".

Example 3:

Input: s = "a#c", t = "b"

Output: false

Explanation: s becomes "c" while t becomes "b".


You are given a string s consisting of lower case English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them. We repeatedly make duplicate removal on s until we no longer can. Return the final string after all such duplicate removals have been made.

Example:

Input : s = "abbaca"

Output :  "ca"

1. remove bb

2. remove aa


Let $T=\underbrace{333\cdots 3}_{3^{2024}}$. Find the largest power of $3$ that can divid $T$.


Lifting The Exponent (LTE) Let $v_p(n)$ be the largest power of a prime $p$ that divides a positive integer $n$, and $x$, $y$ be any two integers such that $p \not\mid x$ and $p \not\mid y$, then

  • When $p$ is odd
    • If $p\mid x-y$, then $v_p(x^n-y^n) = v_p(x-y)+v_p(n)$
    • If $n$ is odd and $p\mid x+y$, then $v_p(x^n+y^n) = v_p(x+y)+vp(n)$
    • If $n$ is even and $p\mid x+y$, then $v_p(x^n+y^n) = 0$
  • When $p=$
    • If $2\mid x-y$ and $n$ is even, then $v_2(x^n-y^n)=v_2(x-y)+v_2(x+y)+v_2(n)-1$
    • If $2\mid x-y$ and $n$ is odd, then $v_2(x^n-y^n)=v_2(x-y)$
  • For all $p$
    • if $gcd(n,p)=1$, and $p\mid x-y$, then $v_p(x^n-y^n)=v_p(x-y)$
    • If $bcd(n,p)=1$, $p\mid x+y$ and n odd, then $v_p(x^n+y^n) = v_p(x+y)$

Given a string s, find the length of the longest substring without repeating characters.

Example 1:

Input: s = "abcabcbb"

Output: 3

Explanation: The answer is "abc", with the length of 3.

Example 2:

Input: s = "bbbbb"

Output: 1

Explanation: The answer is "b", with the length of 1.

Example 3:

Input: s = "pwwkew"

Output: 3

Explanation: The answer is "wke", with the length of 3.

Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.