- 博客(46)
- 问答 (1)
- 收藏
- 关注
原创 求最长回文子串(多种解法)
5. Longest Palindromic Substring save to favoriteQuestionEditorial Solution My SubmissionsTotal Accepted: 128401Total Submissions: 539109Difficulty: Medium
2016-09-05 17:10:51 701
原创 滴滴面试和网易游戏面试分享
滴滴面试,不能用乱来形容。早9点去的,一直在晚上6点才回。1面,给定一个大文件,里边全是ip地址,再给你一个ip,让你设计一个算法,找出这个ip是否存在于这个大文件中。还要求手写整个代码。说出来了好几种思路,和面试官无法愉快的交流,申请换岗。重新面试。1面,给一个二维排序数组,从左到右,从上到下 递增,给你一个数,问你是否存在于这个数组中。其他问题,不记得了,不列举了,一面还算轻松
2016-09-30 14:47:35 1624 3
原创 今日头条面试经验分享
1.给一个小顶堆,再给你一个数,让你插入到这个堆里。思路:把这个数放到堆的最后,然后向上调整堆的最后一个非叶子结点。2.求一个 字符串的 最长回文子串 并且返回第一个出现的下标。思路:中心扩展法,逆序。3.有一个表,有id,name,age等字段,让你查找姓 “李”和姓“王” 并且年龄>18岁的 记录。select * from table where age>18 and
2016-09-28 20:03:00 7434 2
转载 迷宫问题:BFS
原文地址:http://blog.csdn.net/u013480600/article/details/25486071POJ 3984 迷宫问题(BFS:迷宫最短路径且输出路径)http://poj.org/problem?id=3984题意:定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0,
2016-09-28 09:37:43 484
原创 二叉树前序遍历和中序遍历及后续遍历非递归
1.前序遍历 非递归/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} *
2016-09-27 09:50:01 534
原创 矩阵相乘法(稀疏矩阵)
public class Solution { public int[][] multiply(int[][] A, int[][] B) { int[][] C = new int[A.length][B[0].length]; for(int i=0; i<A.length; i++) { for(int j=0;
2016-09-27 09:20:39 432
原创 大数取余
//将“14689”看成多项式相加的和,即1*10^5+4*10^4+6*10^3+8*10^2+9*10^1,每一项如果看成X,Y,Z//结合一些模运算的性质来考虑,比如,对多个数字的相加再求模和先对中间部分结果求模再相加后面的数再求模的结果是一样的//即 (X+Y+Z)modP =((X+Y)modP+ Z)modP = ((XmodP +Y)modP+Z)modP/*
2016-09-27 09:06:29 666
原创 Longest valid Parentheses(括号匹配长度问题)
原文地址:https://leetcode.com/problems/longest-valid-parentheses/题意:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substr
2016-09-24 15:44:17 461
原创 2017小米服务端开发笔试(求二叉树高度)
、本题的思路:dfs#include #include #include #include #include #include #include #include #include #include #include #include #include #include #i
2016-09-23 21:33:22 1091 1
原创 栈(括号匹配问题)
20. Valid Parentheses题目地址:https://leetcode.com/problems/valid-parentheses/题意:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is
2016-09-23 18:36:06 482
原创 网易游戏开发面试题分享
原贴地址:http://www.zhihu.com/question/300342221. inline关键字是做什么用的?inline关键字在什么情况下会展开失败?sizeof一个空类是多大?为什么?编译器为什么这么做?1个字节,任何一个实例在内存中都有一个独一无二的地址,为了达到这个目的,编译器往往会给一个空类隐含的加一个字节,这样空类在实例化后在内存得到了独一无二的地
2016-09-22 15:16:52 8851
原创 常见排序算法的稳定性
堆排序、快速排序、希尔排序、直接选择排序 不是稳定的排序。基数排序、冒泡排序、直接插入排序、折半插入排序、归并排序是稳定的排序算法。首先,排序算法的稳定性,通俗的讲就是能保证排序前2个相等的数在序列的前后位置顺序和排序后它们两个的前后位置顺序相同。那么,稳定性的好处在哪里呢。排序算法如果是稳定的,那么从一个键上排序,然后再从另一个键上排序,第一个键排序的结果可以为第二个键排序所用。
2016-09-21 21:37:42 412
原创 n从1开始,每一个可以选择对n加1或者对n加倍,若想获得整数2013,最少需要多少个操作
n从1开始,每一个可以选择对n加1或者对n加倍,若想获得整数2013,最少需要多少个操作。这里给出一种解答:2013=2*1006+1 (2次)1006=503*2 (1次)503 = 251*2+1 (2次)125=62*2+1 (2次)31=15*2+1 (2次)15=7*2+1 (2次)7=3*2+1
2016-09-21 21:16:42 10166 2
原创 划分宝石问题(2017搜狐笔试题)
同学笔试,帮做了一道算法,题目如下:分析:我想到的首先是判断 这个学者能否得到宝石,也就是要求ABCDE必须至少都出现一次。如果没有的话,直接得不到宝石,返回0,。否则,就是能得到宝石,那么我们仅需要找两个宝石之间的最大间隔就可以了,需要注意的点就是项链是环形的,因此我们需要记录第一个宝石的位置和最后一个宝石的位置即可。代码如下,因为时间仓促,代码比较乱,各位见谅。int ge
2016-09-21 17:13:32 1192
原创 leetcode Anagrams Group(回文构词 分组)
题目链接:https://leetcode.com/problems/anagrams/题意:Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat"
2016-09-21 15:52:52 629
原创 leecode:countandsay(数列模拟)
题目链接:https://leetcode.com/problems/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
2016-09-21 14:12:11 438
原创 Roman to Integer &&Integer to Roman
首先我们看下什么是Roman Interger罗马数字一共有7个,即I,V,X,L,C,D,M规则:重复次数:一个罗马数字重复几次,就表示这个数的几倍右加左减:在一个较大的罗马数字的右边记上一个较小的罗马数字,表示大数字加小数字。在一个较大的数字的左边记上一个较小的罗马数字,表示大数字减小数字。但是,左减不能跨越一个位数。比如,99不可以用IC表示,
2016-09-21 11:35:53 347
原创 strtod()函数
strtod()含义:将字符串转换成浮点数头文件:#include定义函数:double strtod(const char *nptr, char **endptr);函数说明:strtod()会扫描参数nptr字符串,跳过前面的空格字符,直到遇上数字或者正负符号才开始做转换,到出现非数字或字符串结束时('\0')才结束转换,并将结果返回。若endptr不为NULL,则会
2016-09-21 10:28:31 1156
原创 Longest Common Prefix(最长公共前缀)
Write a function to find the longest common prefix string amongst an array of strings.题目链接:https://leetcode.com/problems/longest-common-prefix/思路:1.纵向扫描。从位置0开始,对每一个位置比较所有字符串,直到遇到一个不匹配。代码:cla
2016-09-20 20:55:40 546
原创 招银科技面试经验
突然接到杭州的电话,招银科技。1.挑一个项目,讲述了十分钟。2.瀑布模型的几个阶段。3.如何实现 环形队列。4.虚析构函数的作用。5.char a[] 和 char *a的区别。6. char b[]="123";char *a = b;求a的长度。7.内连接和外连接以及交叉连接。一共用时20min左右,项目叙述时,隔着电话沟通太不自然了。
2016-09-20 14:03:32 11659 9
原创 经典问题:最长回文子串
最长回文子串,非常经典的问题。题意:给定一个字符串,求其最长回文子串。解法一:暴力解法,找出字符串中的所有子串,【时间复杂度O(n^2)】然后求该子串是不是回文串【时间复杂度O(n),所以整个算法的时间复杂度是O(n^3)】,并记录其中最长子串的起始位置和长度。代码如下:class Solution {public: string longestPalindrome(stri
2016-09-20 11:15:01 494
原创 Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".对应leetcode上67题:https://leetcode.com/problems/add-binary/题解:此题不难,但是要写得精炼,还是要学习下
2016-09-20 09:41:55 389
原创 atoi函数实现
对应leetcode: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 as
2016-09-20 08:52:37 354
原创 strstr()实现
题意:implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.题解:直接暴力解法,O(m*n)。class Solution {public: int strStr(
2016-09-19 10:56:15 342
原创 Valid Palindrome(回文字符串)
描述:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car"
2016-09-19 10:44:21 296
原创 LeetCode: Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it t
2016-09-19 10:03:05 334
原创 判断链表是否有环及找环
对应题一:141. Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?分析:最容易想到的方法,用一个哈希表unorderd_map visited,记录每个元素是否
2016-09-19 09:33:02 383
转载 十大措施保证系统安全性
原文地址: http://www.cnblogs.com/yangyy753/archive/2011/11/17/2252774.html 最近在完善一个后台管理系统,上级的需求是安全,安全,再安全,汗……我也知道一个系统的安全是多么的重要,下面是网上摘下来十个比较重要的保护措施,总结一下给大家,喜欢的就可以收藏一下,觉得有更好的可以提出来,大家一起学习。一、 MD5
2016-09-15 11:10:14 756
转载 内存泄露和野指针的概念
内存泄漏 用动态存储分配函数动态开辟的空间,在使用完毕后未释放,结果导致一直占据该内存单元,不能被任何程序再次使用,直到程序结束。即所谓内存泄漏。 注意:内存泄漏是指堆内存的泄漏。 简单的说就是申请了一块内存空间,使用完毕后没有释放掉。它的一般表现方式是程序运行时间越长,占用内存越多,最终用尽全部内存,整个系统崩溃。由程序申请的一块内存,且没有任何一个指针指向它,那么这
2016-09-15 11:05:43 375
原创 站在面试官的高度去想问题
师兄为某公司的面试官,偶然探讨求得面试经验。总结之。A运气是实力的一部分面试至少有一半是看缘分与运气!虽然竭力做到公平公正,但毕竟主管因素太多。你前面一位面试者表现水平一定会在某种程度上改变面试官对你的评判标准。上午面试官一般心情比较好,而下午因为没午睡可能会对世界(更别提你了)产生些许的恶意。不同面试官标准可能差距巨大:有的面试官喜欢嗓门大的,有的喜欢沉稳的,有的喜欢能讲相声
2016-09-12 09:15:05 798
原创 Gas station
原题链接:https://leetcode.com/problems/gas-station/题意:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank an
2016-09-11 11:22:21 385
原创 permutation相关问题
题目描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowe
2016-09-08 15:52:56 533
原创 装水问题(求最大容量)
题目链接:https://leetcode.com/problems/container-with-most-water/题意:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are dra
2016-09-06 21:04:46 2589
原创 Palindrome Number(求一个数是否是回文整数)
原题地址:https://leetcode.com/problems/palindrome-number/原题题意:Determine whether an integer is a palindrome. Do this without extra space.解析:此题可以借用前面的题目:求回文串 的思路将一个int 转化为string,进而就变成了求回文串的 题目。clas
2016-09-06 15:06:11 442
原创 ZigZag Conversion
原题链接:https://leetcode.com/problems/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 patter
2016-09-06 10:38:01 326
原创 赛马问题
36匹马分6个跑道用最快的方法找出跑的最快的6匹马,最少需要比赛几次。36匹马分6个组,分别为A、B、C、D、E、F组.第一轮,每个组各跑一次,取每组前三名,标识为A1、A2、A3,B1、B2、B3,以此类推.第二轮,每个组的第一名(A1——F1)拉出来跑一次,假设名次是:A1第一名,B1第二名,C1第三名.则:1.后三名及其所在组的其余组员均被淘汰(小组头名都没能进前
2016-09-04 22:01:36 467
原创 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "
2016-09-04 13:11:07 344
原创 设计模式题库
1.设计模式的原理? (C)A.面对实现编程B. 面向对象编程C. 面向接口编程D. 面向组合编程 2. 以下对"开-闭"原则的一些描述错误的是?(A)A. "开-闭"原则与"对可变性的封装原则"没有相似性.B. 找到一个系统的可变元素,将它封装起来,叫"开-闭"原则C. 对修改关闭: 是其原则之一D. 从抽象层导出一个或多个新的具体类可以改变系统的行为,是
2016-09-04 10:45:58 7880 2
转载 leetcode 2 : Add two numbers
Add Two NumbersYou 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
2016-09-03 10:15:31 465
原创 C++拷贝构造函数的使用时机 笔试题
#includeusing namespace std;classMyClass{public: MyClass(inti = 0) { cout } MyClass(constMyClass &x) { cou
2016-09-02 15:25:05 578
空空如也
WPF图片显示放大缩小,与绘制直线,折线,矩形
2017-02-26
TA创建的收藏夹 TA关注的收藏夹
TA关注的人