Q: Implement sum() so that the following expressions evaluate correctly: sum(1, 2, 3).sumOf(); // 6 sum(2, 3)(2).sumOf(); // 7 sum(1)(2)(3)(4).sumOf();…
Every unique item in the input appears exactly 3 times. Examples: [1, 1, 1] => true [1, 2, 3] => false Consider a cache-like data structure with operati…
Card game N players randomly draw 4 cards per person. Winning rule Same color Same number Sequential 这道题给出多人随机抽取 4 张牌的设定,需要根据手牌判断获胜条件是否满足:同色、同数字、或连续顺子。核…
Problem Description Input: N (1-20) Requirement: Count how many numbers with at most N digits do not contain consecutive digit 6 s. Example: 2, 0~99, in…
Assume you run a movie theater that has many auditoriums, and every day you need to schedule movies into those auditoriums. You want to schedule all mov…
Given a string s containing just the characters ( , ) , { , } , [ and ] , determine if the input string is valid. An input string is valid if: Open brac…
You are given an array of integers and another target integer as input. Your task is to return the index or indices of the target integer in the array a…
Given a string, return the longest recurring substring. 这道题要求在一个字符串中找出最长的重复子串,也就是在原串中至少出现两次的连续子串,并返回长度最长的那个。常见思路是结合后缀数组、后缀树,或者用二分答案配合哈希/滚动哈希来判断某个长度的子串是否…
National Park – BPC Definition: We are building a system that can track the campgrounds at a National Park as well as the attractions available for gues…
You can select any programming language. Implement a basic Pub/Sub following the given interface. // Interface interface Subscription { unsubscribe(): v…
You are to build a simple key-value store for storing integers (keys are strings, values are integers) and a global version number (integer). You will n…
We are designing a system for officers to check out a body worn camera from a pool of available cameras. We need an object to store a collection of came…
Problem: Given a 2D array of integers representing a paint canvas, where each integer represents a color, write a function that takes a point in the arr…
Design a new service for users to create playlists and store songs in them. Functional requirements Users can create any number of playlists. Users can…
Robinhood is famous for its referral program. It’s exciting to see our users spreading the word across their friends and family. One thing that is inter…
Two strings are said to be similar if they are composed of the same characters. For example, “abaca” and “cba” are similar since both of them are compos…
Given an array of N integers containing integers from 1 to N only. Some numbers may appear multiple times, some numbers may not appear. Write code to pr…
Implement the functionality of the “find” command in UNIX as an API that returns a list of files matching the provided search parameters. The search sho…