随笔分类 - 算法题
摘要:Description:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element fro...
阅读全文
摘要:Description:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 ...
阅读全文
摘要:Description:Write a SQL query to find all numbers that appear at least three times consecutively.+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 ...
阅读全文
摘要:Description:Given an integer, write a function to determine if it is a power of two.public class Solution { public boolean isPowerOfTwo(int n) { ...
阅读全文
摘要:Description:Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / ...
阅读全文
摘要:Description:Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), th...
阅读全文
摘要:Description:Implement int sqrt(int x).Compute and return the square root of x.好好学习数学还是非常有用的,牛顿迭代法 求解。 计算x2= n的解,令f(x)=x2-n,相当于求解f(x)=0的解,如左图所示。 首先取x0,...
阅读全文
摘要:Description:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will r...
阅读全文
摘要:Description:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must b...
阅读全文
摘要:超时了,只能先这么干了。return Math.pow(x, n);
阅读全文
摘要:Description: Given an array of integers, every element appears three times except for one. Find that single one.只有一个出现一次的数字,其他的都出现了3次,找出出现一次的那个数字。pub...
阅读全文
摘要:Description:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5",...
阅读全文
摘要:Description:Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the large...
阅读全文
摘要:Description:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct eleme...
阅读全文
摘要:Description:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the...
阅读全文
摘要:Description:Given an array of integers, every element appears twice except for one. Find that single one.找出只出现一次的数。public class Solution { public i...
阅读全文
摘要:Description:https://leetcode.com/problems/rectangle-area/public class Solution { public int computeArea(int A, int B, int C, int D, int E, int F, i...
阅读全文
摘要:Description:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any posi...
阅读全文
摘要:Description:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint...
阅读全文
摘要:Description:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A...
阅读全文
浙公网安备 33010602011771号