随笔分类 -  Algorithm

摘要:要求 有N个1到1000之间的随机整数(N≤1000),对于其中重复的数字,只保留一个,把其余相同的数去掉,然后再把这些数从小到大排序输出。 形式 Input Param n 输入随机数的个数 inputArray n个随机整数组成的数组 Return Value OutputArray 输出处理后 阅读全文
posted @ 2020-01-20 13:00 执白 阅读(376) 评论(0) 推荐(0)
摘要:题目 写出一个程序,接受一个由字母和数字组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。 输入描述: 第一行输入一个有字母和数字以及空格组成的字符串,第二行输入一个字符。 输出描述: 输出输入字符串中含有该字符的个数。 eg: 输入 ABCDEF A 输出 复制 1 解 阅读全文
posted @ 2020-01-20 00:42 执白 阅读(537) 评论(0) 推荐(0)
摘要:Q: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 阅读全文
posted @ 2019-09-01 21:58 执白 阅读(132) 评论(0) 推荐(0)
摘要:Remove Nth Node From End of List Given a linked list, remove the n-th node from the end of list and return its head. Example: Note: Given n will alway 阅读全文
posted @ 2019-08-25 21:35 执白 阅读(112) 评论(0) 推荐(0)
摘要:Q: 给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。 注意: 答案中不可以包含重复的四元组。 示例: 给定数组 nums 阅读全文
posted @ 2019-07-13 17:15 执白 阅读(154) 评论(0) 推荐(0)
摘要:Q: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to 阅读全文
posted @ 2019-07-06 18:22 执白 阅读(179) 评论(0) 推荐(0)
摘要:3Sum Closest Q: Given an array nums of n integers and an integer target , find three integers in nums such that the sum is closest to target . Return  阅读全文
posted @ 2019-06-28 08:32 执白 阅读(120) 评论(0) 推荐(0)
摘要:3Sum Q: Given an array nums of n integers, are there elements a , b , c in nums such that a + b + c = 0? Find all unique triplets in the arr 阅读全文
posted @ 2019-06-28 08:29 执白 阅读(139) 评论(0) 推荐(0)
摘要:Q: Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Exa 阅读全文
posted @ 2019-06-21 21:11 执白 阅读(120) 评论(0) 推荐(0)
摘要:Q: 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 e 阅读全文
posted @ 2019-06-15 15:59 执白 阅读(126) 评论(0) 推荐(0)
摘要:一、问题 二、解决 JAVA JAVASCRIPT 网上看到还有一种更高效的方法,然而没看懂。。。留待研究 阅读全文
posted @ 2019-05-13 09:15 执白 阅读(184) 评论(0) 推荐(0)
摘要:ps:城际的网速还是不错的~ 阅读全文
posted @ 2019-04-26 07:44 执白 阅读(185) 评论(0) 推荐(0)
摘要:一、question You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their n 阅读全文
posted @ 2019-04-22 09:02 执白 阅读(174) 评论(0) 推荐(0)
摘要:一、问题 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 二、解决 (堆栈方法) (数学方法) ps.数学方法的用时要比调用堆栈快很多。 阅读全文
posted @ 2019-04-07 17:16 执白 阅读(195) 评论(0) 推荐(0)
摘要:一、问题 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 二、解决 阅读全文
posted @ 2019-04-01 08:37 执白 阅读(186) 评论(0) 推荐(0)
摘要:一、问题 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 二、解决 阅读全文
posted @ 2019-03-24 18:04 执白 阅读(205) 评论(0) 推荐(0)
摘要:题目: 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 示例: 解答: 阅读全文
posted @ 2019-03-16 23:10 执白 阅读(168) 评论(0) 推荐(0)