- 博客(72)
- 资源 (2)
- 收藏
- 关注
原创 去哪儿2017编程题
问题:对于每个测试实例,要求输出大于n的下一个对称数字。 分析:最小的对称数字必然是改变靠近对称轴的数字,因此对于输入的数字可以分成以下2种: 1)对称轴左边的数字大于对应位置的右边数字,此时直接将对称轴左边的数字对称到右边即可: 3840 -> 3883; 342 -> 343; 2)对称轴左边的数字小于或者等于对应位置的右边数字,此时,最小的对称数字必然是将对称轴左边的第
2017-09-26 15:03:52
460
原创 秋招阶段性总结(感悟)(2017-9-21)
互联网公司的招聘从3、4月份的实习招聘开始,到6、7月份的内推,再到9、10月份的秋招,真是从悠悠闲闲,到有些着急,再到匆匆忙忙火急火燎,不堪回首。。。。 实习招聘:我们组导师的惯例是不让出去实习,所以我一开始就没有找实习,但是在5月份左右,师兄们都劝说没事实习经历在秋招时会非常吃亏,我也就匆匆忙忙投了2个公司,但是好多公司的实习招聘已经结束,so。。。。。 内推:重度拖延患者伤不起,由于前一段
2017-09-21 22:10:26
478
转载 LeetCode: 672. Bulb Switcher II
There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly m unknown operations towards buttons, you need to return how many different kinds of st
2017-09-17 22:25:53
348
原创 LeetCode: 22. Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())", "(
2017-09-17 21:44:25
280
原创 LeetCode:539. Minimum Time Difference
Given a list of 24-hour clock time points in “Hour:Minutes” format, find the minimum minutes difference between any two time points in the list. Example 1:Input: ["23:59","00:00"]Output: 1Note:The nu
2017-09-15 21:01:06
347
原创 LeetCode: 498. Diagonal Traverse
Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Outp
2017-09-15 20:27:33
333
原创 LeetCode:445. Add Two Numbers II
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it
2017-09-15 19:46:29
225
原创 LeetCode: 421. Maximum XOR of Two Numbers in an Array
Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.Could you do this in O(n) runtime?Example:Input: [3, 10, 5, 25, 2,
2017-09-15 15:13:21
287
原创 LeetCode:384. Shuffle an Array
Discuss Pick One <!-- @END Action Button--> <div class="question-description"> <p></p><p>Shuffle a set of numbers without dup
2017-09-14 21:25:01
393
转载 LeetCode 382. Linked List Random Node
题目描述:LeetCode 382. Linked List Random NodeGiven a singly linked list, return a random node’s value from the linked list. Each node must have the same probability of being chosen.Follow up:What if the
2017-09-14 20:07:37
265
原创 LeetCode:529. Minesweeper
Let’s play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing the game board. ‘M’ represents an unrevealed mine, ‘E’ represents an unrevealed empty square, ‘B’ r
2017-09-13 09:35:25
242
原创 LeetCode:462. Minimum Moves to Equal Array Elements II
Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1
2017-09-11 10:49:50
233
原创 网易2018校招编程题
一个合法的括号匹配序列被定义为: 1. 空串”“是合法的括号序列 2. 如果”X”和”Y”是合法的序列,那么”XY”也是一个合法的括号序列 3. 如果”X”是一个合法的序列,那么”(X)”也是一个合法的括号序列 4. 每个合法的括号序列都可以由上面的规则生成 例如”“, “()”, “()()()”, “(()())”, “(((()))”都是合法的。 从一个字符串S中移除零个或者多个字符得到的序列
2017-09-10 13:08:28
2339
原创 网易2018年编程题
魔法王国一共有n个城市,编号为0~n-1号,n个城市之间的道路连接起来恰好构成一棵树。 小易现在在0号城市,每次行动小易会从当前所在的城市走到与其相邻的一个城市,小易最多能行动L次。 如果小易到达过某个城市就视为小易游历过这个城市了,小易现在要制定好的旅游计划使他能游历最多的城市,请你帮他计算一下他最多能游历过多少个城市(注意0号城市已经游历了,游历过的城市不重复计算)。输入描述:输入包括两行,第
2017-09-10 11:42:07
4223
原创 LeetCode:260. Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums = [1
2017-09-09 17:31:21
244
原创 Java基础:Java 强制类型转换
Java类型转换包括基本数据类型的类型转换以及对象类型转换。 1、基本数据类型转换 java基本数据类型包括:boolean、char、byte、short、int、float、double。其中只有boolean类型无法与其他类型进行转换,其他的数据类型之间可以相互转换。对于byte、short、int、float、double从后向前需要强制类型转换,从前向后可以自动转换。c
2017-09-09 10:54:02
413
原创 LeetCode:526. Beautiful Arrangement
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 <= i <
2017-09-07 20:43:15
316
原创 LeetCode:553. Optimal Division
Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of parenthesis at any position to change the
2017-09-07 20:06:27
386
原创 LeetCode:647. Palindromic Substrings
Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consist of
2017-09-07 19:12:04
241
原创 LeetCode:406. Queue Reconstruction by Height
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this p
2017-09-07 18:22:33
238
原创 LeetCode:442. Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra space
2017-09-07 16:06:20
222
原创 LeetCode:419. Battleships in a Board
Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:You receive a valid board,
2017-09-07 15:31:18
218
原创 LeetCode: 479. Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should return the largest palindrome mod 1337.Example:Input: 2Output: 987Explanat
2017-09-06 21:49:47
1330
转载 LeetCode:204. Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.Credits:Special thanks to @mithmatt for adding this problem and creating all test cases. 题意:输出小于n的素数(质数)的数目。(《编程之
2017-09-06 18:41:20
197
原创 LeetCode: Add to List 414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2, 1]Outpu
2017-09-06 17:23:14
216
原创 LeetCode: 581. Shortest Unsorted Continuous Subarray
Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. You need to find t
2017-09-05 14:21:22
195
原创 Leetcode:611. Valid Triangle Number
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.Example 1:In
2017-09-04 21:38:09
242
原创 Leetcode:621. Task Scheduler
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could be
2017-09-04 21:23:03
231
原创 665. Non-decreasing Array
Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.We define an array is non-decreasing if array[i] <= array[i + 1] holds for every i
2017-09-01 21:59:01
510
原创 LeetCode 667. Beautiful Arrangement II
Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is [a1, a2, a3, … , an],
2017-09-01 20:54:23
754
原创 Leetcode 115. Distinct Subsequences
问题描述 Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleti
2017-07-12 16:59:14
223
原创 Leetcode 97. Interleaving String
问题描述 Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", r
2017-07-12 16:11:09
283
原创 Leetcode 87. Scramble String
问题描述 Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great /
2017-07-12 10:57:44
277
原创 Leetcode 72. Edit Distance
问题描述 Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted o
2017-07-11 22:05:31
225
原创 Leetcode 32. Longest Valid Parentheses
问题描述 Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "
2017-07-11 16:36:51
241
转载 Leetcode 174. Dungeon Game
问题描述 table.dungeon, .dungeon th, .dungeon td { border:3px solid black;} .dungeon th, .dungeon td { text-align: center; height: 70px; width: 70px;}The demons had captured the p
2017-07-10 22:20:49
236
转载 Leetcode 188. Best Time to Buy and Sell Stock IV
问题描述 Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may
2017-07-10 19:57:30
286
原创 Leetcode 213. House Robber II
问题描述 Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. T
2017-07-10 16:00:25
240
数据结构课程设计
2013-09-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人