CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 930. Binary Subarrays With Sum

Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array. Example 1:Input: nums = [1,0,1,0,1], goal &#
2021-05-05
#leetcode #java #array #hashmap #prefix sum #sliding window

[LeetCode] 1845. Seat Reservation Manager

Design a system that manages the reservation state of n seats that are numbered from 1 to n. Implement the SeatManager class: SeatManager(int n) Initializes a SeatManager object that will manage n se
2021-05-02
#leetcode #java #design #heap

[LeetCode] 1244. Design A Leaderboard

Design a Leaderboard class, which has 3 functions: addScore(playerId, score): Update the leaderboard by adding score to the given player’s score. If there is no player with such id in the leaderboard,
2021-04-27
#leetcode #java #hashmap #sort #design

[LeetCode] 1838. Frequency of the Most Frequent Element

The frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the elem
2021-04-26
#leetcode #array #greedy #prefix sum #sort #sliding window

[LeetCode] 1670. Design Front Middle Back Queue

Design a queue that supports push and pop operations in the front, middle, and back. Implement the FrontMiddleBack class:FrontMiddleBack() Initializes the queue.void pushFront(int val) Adds val to the
2021-04-18
#leetcode #java #design #queue

[LeetCode] 1704. Determine if String Halves Are Alike

You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half. Two strings are alike if they have the same number of
2021-04-08
#leetcode #java #two pointer #string

[LeetCode] 1749. Maximum Absolute Sum of Any Subarray

You are given an integer array nums. The absolute sum of a subarray [numsl, numsl+1, …, numsr-1, numsr] is abs(numsl + numsl+1 + … + numsr-1 + numsr). Return the maximum absolute sum of any (possibly
2021-03-25
#leetcode #java #array #greedy #prefix sum

[LeetCode] 1801. Number of Orders in the Backlog

You are given a 2D integer array orders, where each orders[i] = [price, amount, orderType] denotes that amount orders have been placed of type orderType at the price price. The orderTyp is:0 if i
2021-03-22
#leetcode #java #MOD #greedy #heap

[LeetCode] 841. Keys and Rooms

There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. When you
2021-03-21
#leetcode #bfs #dfs #java #graph

[LeetCode] 670. Maximum Swap

You are given an integer num. You can swap two digits at most once to get the maximum valued number. Return the maximum valued number you can get. Example 1:Input: num = 2736Output: 7236Explanati
2021-03-18
#leetcode #java #array #greedy #math
1…2021222324…44

Search

Hexo Fluid