每天一道编程系列
文章平均质量分 59
yesr2014
大连理工大学软件工程专业本科生
展开
-
【每天一道编程系列-2018.1.31】(Ans)
【题目描述】Enter a certain day of a year to determine which day is it of the year? 【题目翻译】输入某年某月某日,判断这一天是这一年的第几天? 【解题思路】以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊原创 2018-01-31 12:16:19 · 344 阅读 · 0 评论 -
【每天一道编程系列-2018.3.7】(Ans)
【题目描述】 Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have...原创 2018-03-07 23:44:35 · 377 阅读 · 0 评论 -
【每天一道编程系列-2018.2.18】(Ans)
【题目描述】There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 【题目翻译】两个排序数组,找这两个排序数组的...原创 2018-02-18 23:09:19 · 330 阅读 · 0 评论 -
【每天一道编程系列-2018.2.19】(Ans)
【题目描述】 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 【题目翻译】 给定一个字符串S,...原创 2018-02-19 23:29:32 · 286 阅读 · 0 评论 -
【每天一道编程系列-2018.3.14】—— Trailing Zeros
【题目描述】 O(log N) timeWrite an algorithm which computes the number of trailing zeros in n factorial.Have you met this question in a real interview? YesExample11! = 39916800, so the out should be 2【题目大意】...原创 2018-03-14 22:48:39 · 453 阅读 · 0 评论 -
【每天一道编程系列-2018.2.20】(Ans)
【题目描述】 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 N APLSIIG...原创 2018-02-20 22:41:29 · 419 阅读 · 0 评论 -
【每天一道编程系列-2018.2.28】(Ans)
【题目描述】 Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin...原创 2018-02-28 23:19:45 · 235 阅读 · 0 评论 -
【每天一道编程系列-2018.2.21】(Ans)
【题目描述】 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 【题目大意】输入一个整数对其进行翻转 【解题思路】通过求余数求商法进行操作。【本题答案】/** * @author yesr * @create 2018-02-21 下午11:17 *...原创 2018-02-21 23:13:48 · 232 阅读 · 0 评论 -
【每天一道编程系列-2018.2.22】(Ans)
【题目描述】 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 i...原创 2018-02-22 22:22:30 · 353 阅读 · 0 评论 -
【每天一道编程系列-2018.3.1】(Ans)
【题目描述】 Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 【题目大意】 输入一个数字,将它转成一个罗马数字,输入的数字在[1, 3999]之间。 罗马数字的表示: 个位数举例: (I, 1) (II, 2) (I...原创 2018-03-01 23:19:30 · 277 阅读 · 0 评论 -
【每天一道编程系列-2018.3.2】(Ans)
【题目描述】 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 【题目大意】 给定一个罗马数字,将其转换成对应的整数。 输入的数字在1-3999之间。 【解题思路】 根据罗马数字与整数数字对应关系进行加法操作,如果前一个...原创 2018-03-02 23:09:16 · 471 阅读 · 0 评论 -
【每天一道编程系列-2018.3.11】—— A + B Problem
【题目描述】Write a function that add two numbers A and B. You should not use + or any arithmetic operators. NoticeThere is no need to read data from standard input stream. Both parameters are given in fun...原创 2018-03-11 23:36:03 · 291 阅读 · 0 评论 -
【每天一道编程系列-2018.3.5】(Ans)
【题目描述】Write a function to find the longest common prefix string amongst an array of strings. 【题目大意】 写一个函数找出一个字串所数组中的最长的公共前缀。 【解题思路】 第一步先找出长度最小的字符串,然后将这个字符串与其它的字符串相比找出最短的最公共前缀。 【本题答案】package blog;/...原创 2018-03-05 21:29:18 · 251 阅读 · 0 评论 -
【每天一道编程系列-2018.3.19】—— Digit Counts
【题目描述】Count the number of k's between 0 and n. k can be 0 - 9.Exampleif n = 12, k = 1 in[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]we have FIVE 1's (1, 10, 11, 12)【题目大意】计算数字k在0到n中的出现的次数,k可能是0~9的一个值样例例...原创 2018-03-20 00:16:12 · 389 阅读 · 0 评论 -
过桥问题
【题目描述】 今天无意中看见一道微软面试题,很有意思,大家一起来看一下: 四人夜过桥,步行时间分别为 1、2、5、10 分钟,四人只有一台手电筒,一趟最多两人过桥,一趟过桥须持手电筒,时间以最慢者计,问 17 分钟内可否过桥,如何过桥? 【本题答案】 这个是一位其他的博主做的答案,我先分享给大家:#define S...原创 2018-04-22 00:11:00 · 1181 阅读 · 0 评论 -
Letter Combinations of a Phone Number
【题目描述】 Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. In...原创 2018-04-19 23:42:11 · 205 阅读 · 0 评论 -
【每天一道编程系列-2018.2.17】(Ans)
【题目描述】Write a program that outputs the number of an integer input in the opposite order.【题目翻译】编写程序,对输入的一个整数,按相反顺序输出该数。(今天的题目非常简单,直接上答案)【本题答案】import java.util.Scanner;/** * @author yesr * @create 2...原创 2018-02-17 22:47:40 · 281 阅读 · 0 评论 -
【每天一道编程系列-2018.2.16】(Ans)
【题目描述】 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is...原创 2018-02-16 23:03:49 · 259 阅读 · 0 评论 -
【每天一道编程系列-2018.2.27】(Ans)
【题目描述】 Implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover the entire inp...原创 2018-02-27 23:00:51 · 250 阅读 · 0 评论 -
【每天一道编程系列-2018.2.1】(Ans)
【题目描述】Given a sorted linked list, delete all duplicates such that each element appear only once.For example:Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.原创 2018-02-01 23:40:02 · 273 阅读 · 0 评论 -
【每天一道编程系列-2018.2.2】(Ans)
【题目描述】You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two number原创 2018-02-02 22:56:24 · 328 阅读 · 0 评论 -
【每天一道编程系列-2018.2.8】(Ans)
【题目描述】Reverse digits of an integer.Example :Example1: x = 123, return 321Example2: x = -123, return -321Note: The input is assumed to be a 32-bit signed integer. Your function should return 0 when the...原创 2018-02-08 22:45:03 · 308 阅读 · 0 评论 -
【每天一道编程系列-2018.2.9】(Ans)
【题目描述】Implementation of a given order of 4 integers from large to small【题目翻译】编写程序实现对给定的 4 个整数从大到小的顺序排列【答案】/** * @author: yesr * @date: 2018.2.9 */import java.util.Scanner;public class Test0209 ...原创 2018-02-09 23:47:42 · 312 阅读 · 0 评论 -
【每天一道编程系列-2018.2.5】(Ans)
【题目描述】Given a linked list, remove the nth node from the end of list and return its head.Example 1:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from原创 2018-02-05 22:20:53 · 281 阅读 · 0 评论 -
【每天一道编程系列-2018.2.10】(Ans)
【题目描述】Write a program, enter a character, to determine whether it is lowercase, if so, convert it to uppercase, otherwise, do not convert.【题目翻译】编写程序,输入一个字符,判断它是否为小写字母,如果是,将它转换成大写字母,否则,不转换。【本题答案】/** *...原创 2018-02-10 23:25:07 · 324 阅读 · 0 评论 -
【每天一道编程系列-2018.1.30】(Ans)
【题目描述】Enter a line of characters. Please count the numbers of letters, spaces, numbers, and other characters.【题目翻译】输入一行字符。请统计出其中字母、空格、数字和其它字符的个数。【解题思路】利原创 2018-01-30 10:02:06 · 430 阅读 · 0 评论 -
【每天一道编程系列-2018.1.26】(Ans)
【题目描述】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.【题目翻译】合并两个已排序的链表并将其作为一个新链表返回。原创 2018-01-26 15:40:06 · 262 阅读 · 0 评论 -
【每天一道编程系列-2018.1.29】(Ans)
【题目描述】There are four numbers of 1, 2, 3, and 4. How many three digits numbers can they make up that are different from each other without repeating numbers? How much are they?【题目原创 2018-01-29 18:03:21 · 346 阅读 · 0 评论 -
【每天一道编程系列-2018.2.6】(Ans)
【题目描述】Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.【题目翻译】给定k个有序链表,将其合并为一个有序的链表,并分析复杂度。【解题思路】原创 2018-02-06 23:16:41 · 304 阅读 · 0 评论 -
【每天一道编程系列-2018.2.26】(Ans)
【题目描述】Determine whether an integer is a palindrome. Do this without extra space. 【题目大意】判断一个数字是否是回访字数,不要使用额外的空间。【解题思路】 为了不使用额外的空间,参考了其它的解决,那些解法看起来在isPalindrome方法中没有使用额外参数,但是却使用了方法调用,这个比一个整数消耗的空间更多 ,并没...原创 2018-02-26 23:13:35 · 254 阅读 · 0 评论 -
【每天一道编程系列-2018.2.11】(Ans)[补]
【题目描述】The number of daffodils refers to an n-digit number (n≥3), the sum of the n-th power of the digits in each of its digits, etc.On its own. (For example: 1 ^ 3 + 5 ^ 3 + 3 ^ 3 = 153). Program to f...原创 2018-02-12 21:54:19 · 223 阅读 · 0 评论 -
【每天一道编程系列-2018.2.12】(Ans)
【题目描述】 Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the targ...原创 2018-02-12 22:20:39 · 238 阅读 · 0 评论 -
【每天一道编程系列-2018.3.6】(Ans)
【题目描述】Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c...原创 2018-03-06 23:18:41 · 230 阅读 · 0 评论 -
【每天一道编程系列-2018.2.13】(Ans)
【题目描述】 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it a...原创 2018-02-13 23:12:03 · 343 阅读 · 0 评论 -
Sum
【题目描述】 Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. N...原创 2018-04-21 00:00:38 · 284 阅读 · 0 评论