自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(113)
  • 资源 (5)
  • 收藏
  • 关注

原创 n位数,去除m位,获得最大的值

/*这道题是2017年某游戏公司测试开发工程师笔试的题目,当是在考场上并没有做出来。特意在网上找到了相应的解答,在这里记录下;n位整数,去除m位后,返回的最大值:贪心算法:每一次寻找局部最优,最后达到全局最优思路:1.首先要明白,在一串数中,我们如果要去掉之中n位后还剩下m位,那么剩余的最大数的最高位的位置就不可能在倒数的第m-1位到最后一位里面,不然就凑不齐m

2017-09-18 16:43:30 2609 1

转载 【两个有序数组求中位数】

/*两个有序数组求中位数问题;这个题有很多方法:方法一:排序,找到中位数;方法二:归并排序的思想方法三:转换成求第k小值  *//*思路:使用二分查找,时间复杂度为log(m+n). 该方法的核心是将原问题转变成一个寻找第k小数的问题(假设两个原序列升序排列),这样中位数实际上是第(m+n)/2小的数。所以只要解决了第k小数的 问题,原问题也得以

2017-09-18 11:39:21 851

原创 【面试中关于死锁的四个条件以及如何解决死锁的记录】

概念:一、死锁:如果一个进程集合里面的每个进程都在等待这个集合的其他一个进程才能继续下去,若无外力它们将无法推进,这种情况就是死锁,处于死锁状态的进程称为死锁进程二、死锁产生的原因1、因竞争资源发生的死锁现象:系统中供多个进程共享的资源的数目不足以满足全部的需要时,就会引起请求资源的竞争,而发生死锁现象;2、可剥夺资源:某进程在获得该类资源时,该资源同样可以被其他进程或系统剥夺;

2017-09-14 19:58:43 693

原创 【找零钱问题】

这是一道比较有意思的题,在牛客网网直通BAT算法的题中看到。这里坐下记录:题:我们知道人民币有1、2、5、10、20、50、100这几种面值。现在给你n元,让你计算换成用上面这些面额表示且总数不超过100张,共有几种。比如4元,能用4张1元、2张1元和1张2元、2张2元,三种表示方法。 这题是到动态规划的问题。n找钱的面值只有7种:1,2,5,10,20,50,100;当输入一

2017-09-14 10:33:00 1074

原创 【decode-ways】

题目描述A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determin

2017-09-12 09:08:12 326

原创 【reverse-linked-list-ii】

Reverse a linked list from position m ton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL, m = 2 and n = 4,return1->4->3->2->5->NULL.Note: Given m, n satisfy the f

2017-09-11 10:03:21 244

原创 【restore-ip-addresses】

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.255.11.135", "255.255.111.35"]. (Order do

2017-09-11 09:39:06 251

转载 面试笔试题约瑟夫问题详解

约瑟夫环问题:一圈共有N个人,开始报数,报道M的人自杀,然后重新开始报数,问到最后自杀的人是谁?如图:内环表示人的排列的环,外环表示自杀顺序;上面N=41;M=3最普通的办法就是模拟整个过程:建一个bool数组,true表示此人还活着,false表示已经自杀,可以模拟整个实现int main(){ int N;//人的总数 int M;//间隔多少人 cin >> N

2017-09-10 08:42:22 672

转载 比较详细的讲01背包问题(值得看)

面试笔试经常碰到01背包问题,头疼。这里来详细讲解下;01背包问题:一个背包总容量为V,现在有N个物品,第i个物品体积为weight[i],价值为value[i],现在往背包里面装东西,怎么实现物品价值最大?看到这个问题,可能会想到贪心算法;但是贪心算法其实是不对,例如最少硬币找零问题,要用动态规划。动态规划思想就是解决子问题并记录子问题的解,这样就不用重复解决子问题了。

2017-09-10 08:36:32 343

原创 【unique-binary-search-trees】

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \

2017-09-10 08:18:12 330

原创 【unique-binary-search-trees-ii】

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3

2017-09-09 13:45:56 553

原创 【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", return

2017-09-09 10:10:07 328

原创 【validate-binary-search-tree】

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.Th

2017-09-09 09:51:22 380

原创 【recover-binary-search-tree】

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n ) space is pretty straight forward. Could you devis

2017-09-09 09:44:43 356

原创 【same-tree】

Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.题意:判

2017-09-09 09:24:46 263

原创 【binary-tree-level-order-traversal】

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the

2017-09-09 09:13:15 290

原创 【binary-tree-zigzag-level-order-traversal】

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary

2017-09-09 09:13:02 363

原创 【construct-binary-tree-from-preorder-and-inorder-traversal】

Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.前序和中序重构二叉树;这里用dfs的思想:class Solution {public:

2017-09-09 09:12:43 282

原创 【construct-binary-tree-from-preorder-and-inorder-traversal】

Given inorder and postorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.题意:中序和后序遍历重构二叉树class Solution {public: Tree

2017-09-09 09:12:28 243

原创 【construct-binary-tree-from-preorder-and-inorder-traversal】

Given inorder and postorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.题意:中序和后序遍历重构二叉树class Solution {public: TreeNo

2017-09-09 09:12:13 294

原创 【binary-tree-level-order-traversal-ii】

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree{3,9,20,#,#,15,7},

2017-09-08 10:38:00 253

原创 【convert-sorted-array-to-binary-search-tree 】

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:和链表转化成平衡二叉树的思路一样,不过数组找中间位置比较简单class Solution {public: TreeNode* sortedArrayToBST(vector& n

2017-09-08 10:12:57 226

原创 【convert-sorted-list-to-binary-search-tree】

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题意;将排序链表转换成平衡二叉树;每次取中间节点,自然就是平衡二叉树了;思路:自顶向下递归解决,先找到中间节点作为根节点,然后递归左右两部分,所以我们先需要连找到

2017-09-08 09:56:43 244

原创 【balanced-binary-tree】

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2017-09-08 09:10:13 199

原创 【path-sum】

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree andsum =

2017-09-08 08:55:57 237

原创 【path-sum-ii】

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \

2017-09-08 08:52:01 239

原创 【distinct-subsequences】

Given a string S and a string T, count the number of distinct subsequences ofT in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none

2017-09-08 08:43:10 340

原创 【triangle】

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,

2017-09-08 08:27:40 235

原创 【pascals-triangle-ii】

Given an index k, return the k th row of the Pascal's triangle.For example, given k = 3,Return[1,3,3,1].Note: Could you optimize your algorithm to use only O(k) extra space?题意:输出指定

2017-09-08 08:27:24 388

原创 【populating-next-right-pointers-in-each-node-ii】

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant

2017-09-08 08:26:57 214

原创 【best-time-to-buy-and-sell-stock】

Say you have an array for which the i thelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2017-09-07 16:24:16 315

原创 【best-time-to-buy-and-sell-stock-ii】

Say you have an array for which the i thelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one

2017-09-07 16:20:47 318

原创 【best-time-to-buy-and-sell-stock-iii】

Say you have an array for which the i thelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at most twotransactions.Note: You may n

2017-09-07 16:13:54 252

原创 【binary-tree-maximum-path-sum】

Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return6.

2017-09-07 15:53:33 208

原创 【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"is not a pa

2017-09-07 15:41:46 409

原创 【word-ladder】

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m

2017-09-07 15:24:05 292

原创 【n阶乘求尾数有多少个0】

题目:设计一个算法,计算出n阶乘中尾部零的个数,注意:时间负责度为o(log2)思路:要求n的阶乘,就是求1到n这个数相乘,在这1到n个数中,只有2和5相乘才会出现0,其中10的倍数也是可以看成2和5相乘的结果,所以,可以在1到n之间统计有多少个数是2的倍数以及多少个数是5的倍数就行了。很容易发现2的倍数的数一定多于5的倍数,因此可以只看n前面有多少个5就行。class Solut

2017-09-07 13:36:47 732

转载 Sql中查询的具体应用及子句的优先级

1、简单的查询select * from tablename;2、带条件查询select *form tablename where 3、避免重复查询select distinct(field_name) from table_name;4、NULL和""是不同的;5、带in关键字的查询:用于指定一个列表select * from table_name where

2017-09-07 10:28:03 310

原创 Sql的基本操作之增删查改操作

在面试笔试中经常碰到关于数据库操作的,一直是自己的弱项,这次专门学习下。1、为表添加主键alter table  add primary key(col);例如:alter table tableStudent add primary key(name);2、插入数据insert into (field1, field2, field3....) values(va

2017-09-07 10:04:01 191

原创 C++面试中经常会让手写String类的实现

主要是完成String类的构造函数、拷贝构造函数、赋值构造函数和析构函数。这个类中包括了指针类成员变量m_data,当类中包括指针类成员变量时,一定要重载构造函数、赋值函数、析构函数;下面是具体的实现:class String{public: String(const char* str=NULL);//普通的构造函数 String(const String& other); //

2017-09-07 09:21:36 7160 9

Linux多线程服务端编程:使用muduo+C++网络库试读样章

经典书籍Linux多线程服务端编程:使用muduo+C++网络库试读样章.

2015-11-27

UNix网络编程卷一(第三版)

unix网络编程第三版卷IPC第二版, stevens的经典著作(unix网络编程大师级的人物),每个写网络程序的人都应该都的一套书。这个是中文版,有书签目录

2015-11-18

程序员面试宝典第四版

程序员面试宝典

2015-11-13

c++primer 视频

c++primer 配套视频,对初学者很有帮助

2015-11-07

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除