Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
509. 斐波那契数 - 斐波那契数 (通常用 F(n) 表示)形成的序列称为 斐波那契数列 。该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和。也就是: F(0) = 0,F(1) = 1 F(n) = F(n - 1) + F(n - 2),其中 n > 1 给定 n ,请计算 F(n) 。 示例 1: 输入
DS Interview Question What’s the differences between the poission distribution and normal distribution? LeetCode Question Write a query in SQL to count the number available rooms. Sample table: room roomnumber | roomtype | blockfloor | blockcode | unavailable ---+---+---+---+--- 101 |...
1publicbooleansearch(int[] nums,inttarget) {2if(nums ==null|| nums.length < 1)3returnfalse;4intleft = 0;5intright = nums.length - 1;6intmid;78while(left <=right){9mid = (right + left)/2;10if(nums[mid] ==target){11returntrue;12}13elseif(nums[left] >nums[mid]){14if(num...
Number Range (medium) Search in a Sorted Infinite Array (medium) Minimum Difference Element (medium) Bitonic Array Maximum (easy) 12. Pattern: Top ‘K’ Elements,前K个系列 任何让我们求解最大/最小/最频繁的K个元素的题,都遵循这种模式。 用来记录这种前K类型的最佳数据结构就是堆了(译者注:在Java...
IdQuestionDifficultyFrequencyData StructuresAlgorithms1Two Sum25array + setsort + two pointers2Add Two Numbers34linked listtwo pointers + math3Longest
转载自:LeetCode Question Difficulty Distribution 1 Two Sum 2 5 array sort set Two Pointers 2 Add Two Numbers 3 4 linked list Two Pointers Math 3 Longest Substring Without Repeating Characters 3 2 string Two Pointers hashtable 4 Median of Two Sorted Arrays 5 3 array Binary Search 5 Longest ...
Section 7: Google Array question: first bad version (Easy) Lecture 32 Introduction To The Problem And Brute Force Approach Lecture 33 Optimal Solution Intuition Lecture 34 Optimal solution pseudocode walkthrough Lecture 35 Implementing the code Section 8: Microsoft Math Question: Missing Number (Easy...
class Solution { public int singleNumber(int[] nums) { // 1.任何数异或0都等于原数 // 2.相同的数异或为0 int res = 0; for (int value: nums) { res ^= value; } return res; } } 4.只出现一次的数字2 nowcoder.com/practice/e //num1,num2分别为长度为1的数组。传出参数 //将num1...
Question 202. 快乐数 难度:简单 ❝ 编写一个算法来判断一个数 n 是不是快乐数。 「快乐数」定义为: 对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和。然后重复这个过程直到这个数变为 1,也可能是 无限循环 但始终变不到 1。如果 可以变为 1,那么这个数就是快乐数。如果 n 是快乐数就...