ID |
Platform |
Title |
Technology |
Difficulty |
Description |
Official Solutions |
YT |
---|---|---|---|---|---|---|---|
85 | edabit.com | Scoring System | Problem Solving | Very easy | Andy, Ben and Charlotte are playing a board game. The three of them decided to come up with a new scoring system. A player's first initial ("A", "B" or "C") denotes that player scoring a single point. Given a string of capital letters, return an array of the players' scores. For instance, if ABBACCCCAC is written when the game is over, then Andy scored 3 points, Ben scored 2 points, and Charlotte scored 5 points, since there are 3 instances of letter A, 2 instances of letter B, and 5 instances of letter C. So the array [3, 2, 5] should be returned. Examples calculateScores("A") ➞ [1, 0, 0] calculateScores("ABC") ➞ [1, 1, 1] calculateScores("ABCBACC") ➞ [2, 2, 3] | ||
84 | edabit.com | AlTeRnAtInG cApS | Problem Solving | Very easy | Create a function that alternates the case of the letters in a string (known as Spongecase). Examples alternatingCaps("Hello") ➞ "HeLlO" alternatingCaps("How are you?") ➞ "HoW aRe YoU?" alternatingCaps("OMG this website is awesome!") ➞ "OmG tHiS wEbSiTe Is AwEsOmE!" | ||
73 | edabit.com | Zip It, If You Can? | Problem Solving | Very easy | Given an array of women and an array of men, either: Return "sizes don't match" if the two arrays have different sizes. If the sizes match, return an array of pairs, with the first woman paired with the first man, second woman paired with the second man, etc. Examples zipIt(["Elise", "Mary"], ["John", "Rick"]) ➞ [["Elise", "John"], ["Mary", "Rick"]] zipIt(["Ana", "Amy", "Lisa"], ["Bob", "Josh"]) ➞ "sizes don't match" zipIt(["Ana", "Amy", "Lisa"], ["Bob", "Josh", "Tim"]) ➞ [["Ana", "Bob"], ["Amy", "Josh"],["Lisa", "Tim"]] | ||
71 | leetcode.com | To Lower Case | Problem Solving | Very easy | Given a string s, return the string after replacing every uppercase letter with the same lowercase letter. Example 1: Input: s = "Hello" Output: "hello" Example 2: Input: s = "here" Output: "here" Example 3: Input: s = "LOVELY" Output: "lovely" | ||
70 | leetcode.com | Maximum Average Subarray I | Problem Solving | Easy | You are given an integer array nums consisting of n elements, and an integer k. Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value. Any answer with a calculation error less than 10-5 will be accepted. Example 1: Input: nums = [1,12,-5,-6,50,3], k = 4 Output: 12.75000 Explanation: Maximum average is (12 - 5 - 6 + 50) / 4 = 51 / 4 = 12.75 Example 2: Input: nums = [5], k = 1 Output: 5.00000 | ||
69 | leetcode.com | Largest Number At Least Twice of Others | Problem Solving | Easy | You are given an integer array nums where the largest integer is unique. Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise. Example 1: Input: nums = [3,6,1,0] Output: 1 Explanation: 6 is the largest integer. For every other number in the array x, 6 is at least twice as big as x. The index of value 6 is 1, so we return 1. Example 2: Input: nums = [1,2,3,4] Output: -1 Explanation: 4 is less than twice the value of 3, so we return -1. | ||
68 | leetcode.com | Most Common Word | Problem Solving | Easy | Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique. The words in paragraph are case-insensitive and the answer should be returned in lowercase. Example 1: Input: paragraph = "Bob hit a ball, the hit BALL flew far after it was hit.", banned = ["hit"] Output: "ball" Explanation: "hit" occurs 3 times, but it is a banned word. "ball" occurs twice (and no other word does), so it is the most frequent non-banned word in the paragraph. Note that words in the paragraph are not case sensitive, that punctuation is ignored (even if adjacent to words, such as "ball,"), and that "hit" isn't the answer even though it occurs more because it is banned. Example 2: Input: paragraph = "a.", banned = [] Output: "a" | ||
67 | leetcode.com | Jewels and Stones | Problem Solving | Easy | You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so "a" is considered a different type of stone from "A". Example 1: Input: jewels = "aA", stones = "aAAbbbb" Output: 3 Example 2: Input: jewels = "z", stones = "ZZ" Output: 0 | ||
66 | leetcode.com | Number of Lines To Write String | Problem Solving | Easy | You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of 'a', widths[1] is the width of 'b', and so on. You are trying to write s across several lines, where each line is no longer than 100 pixels. Starting at the beginning of s, write as many letters on the first line such that the total width does not exceed 100 pixels. Then, from where you stopped in s, continue writing as many letters as you can on the second line. Continue this process until you have written all of s. Return an array result of length 2 where: result[0] is the total number of lines. result[1] is the width of the last line in pixels. Example 1: Input: widths = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = "abcdefghijklmnopqrstuvwxyz" Output: [3,60] Explanation: You can write s as follows: abcdefghij // 100 pixels wide klmnopqrst // 100 pixels wide uvwxyz // 60 pixels wide There are a total of 3 lines, and the last line is 60 pixels wide. Example 2: Input: widths = [4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = "bbbcccdddaaa" Output: [2,4] Explanation: You can write s as follows: bbbcccdddaa // 98 pixels wide a // 4 pixels wide There are a total of 2 lines, and the last line is 4 pixels wide. | ||
65 | leetcode.com | Reverse Words in a String III | Problem Solving | Easy | Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: s = "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Example 2: Input: s = "God Ding" Output: "doG gniD" |