0%

Question

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].

Read more »

Question

Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle.

However, there is a non-negative cooling interval n that means between two same tasks, there must be at least n intervals that CPU are doing different tasks or just be idle.

You need to return the least number of intervals the CPU will take to finish all the given tasks.

Example:
Input: tasks = [“A”,”A”,”A”,”B”,”B”,”B”], n = 2
Output: 8
Explanation: A -> B -> idle -> A -> B -> idle -> A -> B.

Read more »

大家好, 我是无尘(dustfree),欢迎来到我的博客空间。

目前是一名研一学生,计算机相关专业,坐标美国西雅图。一直以来都有写文档的习惯,记录自己在学习、面试、成长过程中的心得与感悟。主要包括LeetCode刷题笔记,计算机基础知识积累,技术学习笔记,以及一些面试经验与成长心得。由于在学习过程中踩过不少坑,走了不少弯路,所以记录下来提醒自己勿犯同样的错误,同时也是一份很好的复习资料。

Read more »