
5种解法的算法面试题 来看看你是青铜还是王者?
先来详细描述下这道题。在一个全为正整数的数组中找到总和为给定值的子数组,给出子数组的起始下标(闭区间),举个例子: 在[3 2 1 2 3 4 5]这个数组中,...
先来详细描述下这道题。在一个全为正整数的数组中找到总和为给定值的子数组,给出子数组的起始下标(闭区间),举个例子: 在[3 2 1 2 3 4 5]这个数组中,...
@ 生日悖论: 是指在不少于 23 个人中至少有两人生日相同的概率大于 50%。例如在一个 30 人的小学班级中,存在两人生日相同的概率为 70%。对于 60 ...
前两天逛github看到一道很简单的面试题——如何不用库函数快速求出$\sqrt2$的值,精确到小数点后10位! 第一反应这不很简单嘛,大学数据结构课讲二分查找...
题目链接295. Find Median from Data Stream 在一个有序数组中找中位数,但需要支持再数组中添加新的元素。本来是有序里的,可以很...
题目链接 236. Lowest Common Ancestor of a Binary Tree 根据LCA的定义,二叉树中最小公共祖先就是两个节点p和q...
题目链接 Given a string s, find the longest palindromic subsequence's length in s. Y...
Leetcode 582. Kill Process 好久没刷题,今天来一道比较简单的题目,如果此题作为一道面试题,可以延伸出树的遍历,栈和队列,hashm...
Leetcode 114. Flatten Binary Tree to Linked List 题目意思很简单,就是把一棵二叉数转换为链表,虽然题目中没说...
题目链接:Unique Substrings in Wraparound String 这里加段英文,不是为了凑字数,而是为了让别人搜索题目的时候能搜到我的博客...
题目链接:368. Largest Divisible Subset Given a set of distinct positive integers, fi...
前两天在一个学长面试的时候遇到这样一个题,这里稍微详细说下本文的标题。给你n个任意整数,求排序后相邻两个数之间的最大差值,这里n可能有10^5,整数为任意3...
题目链接:Combination Sum IV Given an integer array with all positive numbers and no ...
题目链接:Search a 2D Matrix II Write an efficient algorithm that searches for a valu...
题目链接:Search a 2D Matrix Write an efficient algorithm that searches for a value i...
Write a program to find the nth super ugly number. Super ugly numbers are positi...
Given n non-negative integers a1, a2, ..., an, where each represents a point at ...
Given a string, find the length of the longest substring without repeating chara...
原题链接:198. House Robber 一句话理解题意,有个偷马贼晚上要偷尽可能值钱的马,但连续两头马被偷会触发报警,问他如何在不触发报警(不...
这道题第一眼看去很难,其实不然,短短几行代码就搞定了。 说一下大概思路,如果是排成一排的n个人,如 1 2 3 4 5 6 7 8 我们要变成 8 7 ...
题目意思很容易理解,学校有n个社团,每个社团只给编号从a到b 的发传单,而且只给隔了c的人发,问最后谁收到的传单是单数,输出他的编号和收到的传单数量。 昨天做这...
#include <string.h> #include <stdio.h> const int maxn = ...
把输入的数加起来,输入0表示结束。 先看我Java代码,用BigINteger类很多东西都不需要考虑,比如前导0什么的,很方...