随笔分类 - 牛客网
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example, Given[100, 4, 200, 1, 3...
阅读全文
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.C++/** * Definition for a point. * ...
阅读全文
摘要:Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?C++/** * Definition for s...
阅读全文
摘要:Sort a linked list using insertion sort.C++/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode ...
阅读全文
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up: Can you solve it without usin...
阅读全文
摘要:There are N gas stations along a circular route, where the amount of gas at station i isgas[i].You have a car with an unlimited gas ta...
阅读全文
摘要:Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which i...
阅读全文
摘要:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization: Nodes...
阅读全文
摘要:Given a binary tree, return the preorder traversal of its nodes' values.For example: Given binary tree{1,#,2,3},1 2 / 3return[1,2,3].N...
阅读全文
摘要:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example: Given the below binary ...
阅读全文
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer o...
阅读全文
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Ret...
阅读全文
摘要:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to t...
阅读全文
摘要:Given a binary tree, return the postorder traversal of its nodes' values.For example: Given binary tree{1,#,2,3},1 \ 2 / 3return[3,2...
阅读全文
摘要:Say you have an array for which the i th element is the price of a given stock on day i.If you were only permitted to complete at most...
阅读全文
摘要:Say you have an array for which the i th element is the price of a given stock on day i.Design an algorithm to find the maximum profit...
阅读全文
摘要:Say you have an array for which the i th element is the price of a given stock on day i.Design an algorithm to find the maximum profit...
阅读全文
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in...
阅读全文
摘要:像素设定 牛客网 程序员面试金典 题目描述 有一个单色屏幕储存在一维数组中,其中数组的每个元素代表连续的8位的像素的值,请实现一个函数,将第x到第y个像素涂上颜色(像素标号从零开始),并尝试尽量使用最快的办法。 给定表示屏幕的数组screen(数组中的每个元...
阅读全文
摘要:高度最小的BST 牛客网 程序员面试金典 C++ Python 题目描述 对于一个元素各不相同且按升序排列的有序序列,请编写一个算法,创建一棵高度最小的二叉查找树。 给定一个有序序列int[] vals,请返回创建的二叉查找树的高度。 C++class Min...
阅读全文

浙公网安备 33010602011771号