GoCalf Calf 的自留地 · 昙花一现

easy

  • 796. Rotate String

    #Problem Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost position. For example, if s = "abcde", then …

    easy
  • 2490. Circular Sentence

    #Problem A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello world hello world" are all sentences. Words consist of only uppercase and lowercase …

    easy
  • 1957. Delete Characters to Make Fancy String

    #Problem A fancy string is a string where no three consecutive characters are equal. Given a string s, delete the minimum possible number of characters from s to make it fancy. Return the final string after the deletion. It can be shown …

    easy
  • 3222. Find the Winning Player in Coin Game

    #Problem You are given two positive integers x and y, denoting the number of coins with values 75 and 10 respectively. Alice and Bob are playing a game. Each turn, starting with Alice, the player must pick up coins with a total value 115. …

    easy
  • 3226. Number of Bit Changes to Make Two Integers Equal

    #Problem You are given two positive integers n and k. You can choose any bit in the binary representation of n that is equal to 1 and change it to 0. Return the number of changes needed to make n equal to k. If it is impossible, return -1. …

    easy
  • 2923. Find Champion I

    #Problem There are n teams numbered from 0 to n - 1 in a tournament. Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team …

    easy
  • 125. Valid Palindrome

    #Problem A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. …

    easy
  • 3206. Alternating Groups I

    #Problem There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]: colors[i] == 0 means that tile i is red. colors[i] == 1 means that tile i is blue. Every 3 …

    easy
  • 121. Best Time to Buy and Sell Stock

    #Problem You are given an array prices where prices[i] is the price of a given stock on the iᵗʰ day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. …

    easy
  • 242. Valid Anagram

    #Problem Given two strings s and t, return true if t is an anagram of s, and false otherwise. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once. …

    easy
  • 104. Maximum Depth of Binary Tree

    #Problem Given the root of a binary tree, return its maximum depth. A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. …

    easy
  • 100. Same Tree

    #Problem Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. …

    easy
  • 226. Invert Binary Tree

    #Problem Given the root of a binary tree, invert the tree, and return its root. https://leetcode.com/problems/invert-binary-tree/ Example 1: case1Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] Example 2: case2Input: root = …

    easy
  • 217. Contains Duplicate

    #Problem Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. https://leetcode.com/problems/contains-duplicate/ Example 1: Input: nums = [1,2,3,1] Output: …

    easy
  • 3238. Find the Number of Winning Players

    #Problem You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xᵢ, yᵢ] represents that the player xᵢ picked a ball of color yᵢ. Player i wins the game if they pick strictly more than i …

    easy
  • 338. Counting Bits

    #Problem Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1’s in the binary representation of i. https://leetcode.com/problems/counting-bits/ Example 1: Input: n = 2 Output: …

    easy
  • 206. Reverse Linked List

    #Problem Given the head of a singly linked list, reverse the list, and return the reversed list. https://leetcode.com/problems/reverse-linked-list/ Example 1: case1Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: case2Input: head = …

    easy
  • 3248. Snake in Matrix

    #Problem There is a snake in an n x n matrix grid and can move in four possible directions. Each cell in the grid is identified by the position: grid[i][j] = (i * n) + j. The snake starts at cell 0 and follows a sequence of commands. You …

    easy
  • 70. Climbing Stairs

    #Problem You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? https://leetcode.com/problems/climbing-stairs/ Example 1: Input: n = …

    easy
  • 191. Number of 1 Bits

    #Problem Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight). A set bit refers to a bit in the binary representation of a number that has a value …

    easy
  • 190. Reverse Bits

    #Problem Reverse bits of a given 32 bits unsigned integer. Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not …

    easy
  • 572. Subtree of Another Tree

    #Problem Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree is a tree that consists of a …

    easy
  • 661. Image Smoother

    #Problem An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue smoother). If …

    easy
  • 21. Merge Two Sorted Lists

    #Problem You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. …

    easy
  • 20. Valid Parentheses

    #Problem Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be …

    easy
  • 268. Missing Number

    #Problem Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. https://leetcode.com/problems/missing-number/ Example 1: Input: nums = [3,0,1] Output: 2 …

    easy
  • 141. Linked List Cycle

    #Problem Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. …

    easy
  • 3258. Count Substrings That Satisfy K-Constraint I

    #Problem You are given a binary string s and an integer k. A binary string satisfies the k-constraint if either of the following conditions holds: The number of 0’s in the string is at most k. The number of 1’s in the string is at most k. …

    easy
  • 3242. Design Neighbor Sum Service

    #Problem You are given a n x n 2D array grid containing distinct elements in the range [0, n² - 1]. Implement the NeighborSum class: NeighborSum(int [][]grid) initializes the object. int adjacentSum(int value) returns the sum of elements …

    easy
  • 1. Two Sum

    #Problem Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. …

    easy