All Posts

Leetcode 1952: Three Divisors

Given an integer n, return true if n has exactly three distinct positive divisors. Otherwise, return false. A divisor of n is a positive integer that divides n without leaving a remainder.

Leetcode 1957: Delete Characters to Make Fancy String

Given a string s, you need to remove the minimum possible number of characters to ensure that no character appears three or more times consecutively in the resulting string. The output should be the final string after all necessary deletions.

Leetcode 1961: Check If String Is a Prefix of Array

You are given a string s and an array of strings words. Determine if the string s can be formed by concatenating the first k strings from the array words, for some value of k, where 1 <= k <= words.length. Return true if s is a prefix of words, or false otherwise.

Leetcode 1971: Find if Path Exists in Graph

You are given a graph with n vertices labeled from 0 to n-1 (inclusive) and edges connecting pairs of vertices. Your task is to determine if there exists a valid path from a given source vertex to a destination vertex. The graph is undirected, and each pair of vertices is connected by at most one edge. The vertices are connected by edges as given in the input.

Leetcode 1974: Minimum Time to Type Word Using Special Typewriter

You are given a special typewriter with lowercase English letters (‘a’ to ‘z’) arranged in a circle. A pointer initially starts at the character ‘a’. Each second, you may perform one of two operations: move the pointer one character clockwise or counterclockwise, or type the character the pointer is currently on. Your task is to determine the minimum number of seconds needed to type the given string word.

Leetcode 1979: Find Greatest Common Divisor of Array

Given an array of integers, your task is to compute the greatest common divisor (GCD) of the smallest and largest elements in the array.