- 博客(36)
- 收藏
- 关注
原创 【2016去哪儿网笔试题】找出输入中有几个死锁
题目大致意思)寻找输入中有几个死锁,首先输入总共有多少条数据。然后一行输入的信息中第一列代表数据id,第二列代表正在占用的资源id(如果有多个,则用逗号分割,没有则为空格),第三列代表申请占用的资源id(如果有多个,则用逗号分割,没有则为空格)。每列之间用制表符分割。判断其中有多少个死锁。输入(为了避免分不清制表符和空格,我在原题的基础上加上了[制表符]和[空格import java.ut
2015-09-21 17:36:13 685
原创 【hihoCoder】#1086: Browser Caching (微软笔试题)
#1086 : Browser Caching时间限制:10000ms单点时限:1000ms内存限制:256MB描述When you browse the Internet, browser usually caches some documents to reduce the time cost of fetching them from remote s
2015-09-16 16:08:53 939
原创 ACM 2001 计算两点间的距离
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem Description输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。Input输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,
2015-09-15 18:28:03 422
原创 【Leetcode Algorithm】Summary Ranges
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","7"].public class Solution { public List summaryRa
2015-07-29 21:12:12 345
原创 【Leetcode Algorithm】Power of Two
Given an integer, write a function to determine if it is a power of two.第一次尝试代码:public class Solution { public boolean isPowerOfTwo(int n) { //如果为0,则false if(n==0){
2015-07-06 21:45:38 285
原创 【Leetcode Algorithm】Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get
2015-07-03 21:24:16 218
原创 【Leetcode Algorithm】Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as
2015-07-03 11:14:02 318
原创 【Leetcode Algorithm】Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially
2015-07-03 10:20:14 570
原创 【Leetcode Algorithm】Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.自己的代码:public class Solution { public int strStr(String hayst
2015-07-02 21:23:48 248
原创 【Leetcode Algorithm】Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.
2015-07-02 21:22:45 248
原创 【Leetcode Algorithm】Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with
2015-07-02 17:03:36 234
原创 【Leetcode Algorithm】Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by Max Howe
2015-07-02 15:20:53 309
原创 【Leetcode Algorithm】Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the tota
2015-07-02 15:19:43 208
原创 【Leetcode Algorithm】Contains Duplicate II
Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between iand j is at most
2015-07-02 15:17:55 319
原创 【Leetcode Algorithm】Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.代码:1234567891011121314151617181920
2015-07-02 15:17:14 608
原创 【Leetcode Algorithm】Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares
2015-07-02 15:15:07 302
原创 【Leetcode Algorithm】Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".自己的代码123456789101112
2015-07-02 15:12:50 237
原创 【Leetcode Algorithm】ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I
2015-07-02 15:10:42 259
原创 【Leetcode Algorithm】String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca
2015-07-02 15:10:09 290
原创 【Leetcode Algorithm】Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.自己的代码:12345678910111213141516
2015-07-02 15:09:19 371
原创 【Leetcode Algorithm】Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va
2015-07-02 15:08:25 262
原创 【Leetcode Algorithm】Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.自己尝试的代码:1234567
2015-07-02 15:07:26 277
原创 链表反转的四种方法分析
关于反转链表的总结:反转链表的方式有很多,现在介绍四种:非递归的:从图中可以看到,对n个节点的反转,方法一指针指向改变了2^(n-1)次,还有一个额外的节点,而方法二用了2^(n-1)次,却没有增加额外节点。方法三既没有增加新节点,指针指向改变了n次,显然方法三好。递归方法很赞,图就不好画了,大家直接看代码。代码:pack
2015-06-11 21:59:07 1379
原创 【Leetcode Database】Employees Earning More Than Their Managers
题目:The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name |
2015-06-11 10:54:39 442
原创 【Leetcode Database】Delete Duplicate Emails
题目:Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.+----+------------------+| Id | Email |+---
2015-06-11 10:43:22 383
原创 【Leetcode Algorithm】Contains Duplicate
题目:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every ele
2015-06-11 10:41:57 240
原创 【Leetcode Algorithm】Reverse Linked List
Reverse a singly linked list.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?第一次尝试:1、创建一个新的链表ln——>null2、创建一个中间节点ln13、头结点head不为空时,ln1—
2015-06-11 10:40:03 226
原创 【Leetcode Algorithm】Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.罗马数字与阿拉伯数字的对应关系基本字符IVXLC
2015-06-11 10:38:38 261
原创 【Leetcode Algorithm】Remove Nth Node From End of List
题目:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from t
2015-06-11 10:35:58 281
原创 【Leetcode Database】Duplicate Emails
题目:Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+
2015-05-05 19:34:38 361
原创 【Leetcode Database】Combine Two Tables
【Leetcode Database】Combine Two Tables,本题主要考察数据库的内连接与外连接。
2015-05-05 14:55:39 487
原创 【Leetcode Shell】Transpose File
题目:Given a text file file.txt, transpose its content.You may assume that each row has the same number of columns and each field is separated by the ' ' character.For example, if file
2015-05-03 12:30:37 884
原创 【Leetcode Shell】Valid Phone Numbers
题目:Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.You may assume that a valid phone number must
2015-05-01 19:04:25 649
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人