自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(144)
  • 资源 (1)
  • 收藏
  • 关注

原创 指针详解(第二篇)

先上例题 1、“` char *p={ “how are you”, “hello”, “what’s your name”};这里p的类型不是char*,而是char * *2、```char a[20]="my name is Jang"char *p=a;char** q=&p;printf("%p",**q);q++;printf("%p",**q);正确输出:第一

2017-03-15 17:55:35 462

原创 C++例题

1、C++与C的区别? C是面对过程的,C++是面对对象的,C是一个结构化语言,它的重点在于算法和数据结构。C程序的设计首要考虑的是如何通过一个过程,对输入(或环境条件)进行运算处理得到输出(或实现过程(事务)控制),而对于C++,首要考虑的是如何构造一个对象模型,让这个模型能够契合与之对应的问题域,这样就可以通过获取对象的状态信息得到输出或实现过程(事务)控制。 所以C与C++的最大区别在于它们

2017-03-14 20:10:36 640

原创 Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path

2017-03-13 10:16:18 405

原创 指针例题详解

void test2()   {   char string[10], str1[10];    int i;   for(i=0; i<10; i++)   {   str1= 'a';   }   strcpy( string, str1 );   }错误: 链接:https://www.nowcoder.com/questionTerminal/f8209ee66a1b43

2017-03-09 21:00:54 718

原创 Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,3,2].Note: Recursive solution is trivia

2017-03-02 09:52:53 384

原创 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,null,null,15,7],

2017-03-02 09:51:24 304

原创 Binary Tree Level Order Traversal

Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20

2017-03-02 08:28:44 268

原创 Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.class Solution {public: int minDepth(T

2017-03-01 19:17:13 305

原创 Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.class Solution {public: int maxDepth(T

2017-03-01 19:12:16 343

原创 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 differ by

2017-03-01 19:11:24 355

原创 Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree:1 / \ 2 3 \ 5 All root-to-leaf paths are:[“1->2->5”, “1->3”]第一个错误版本class Solution {publi

2017-03-01 10:28:58 287

原创 Invert Binary Tree

Invert Binary Tree Add to List Description Submission Solutions Total Accepted: 154920 Total Submissions: 307555 Difficulty: Easy Contributors: Admin Invert a binary tree. 4/ \ 2 7

2017-03-01 08:57:37 263

原创 Flatten Binary Tree to Linked List

Given a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2 \ 3

2017-02-28 22:55:45 451

原创 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./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNo

2017-02-28 22:19:44 341

原创 Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list./** * Definition for singly-linked lis

2017-02-28 20:51:29 303

原创 Insertion Sort List

Sort a linked list using insertion sort.class Solution {public: ListNode* insertionSortList(ListNode* head) { if(!head) return NULL; ListNode* pre=new ListNode(-1),*p=head,*q;

2017-02-28 15:19:01 280

原创 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 to {1,4,2,3}

2017-02-28 14:33:46 326

原创 Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using extra space?class Solution

2017-02-28 10:42:13 228

原创 Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in plac

2017-02-28 09:21:46 243

原创 Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list be

2017-02-28 09:17:11 253

原创 Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the following co

2017-02-25 18:13:04 223

原创 Palindrome Linked List(回文链表)

LintCode原题 Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?class Solution {public: bool isPalindrome(ListNode* head) {

2017-02-25 11:26:21 348

原创 Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the

2017-02-25 11:12:01 210

原创 Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2017-02-24 10:50:57 233

原创 Reverse Linked List

Reverse a singly linked list.原题/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solut

2017-02-23 20:47:39 278

原创 Linked List Cycle

Given a linked list, determine if it has a cycle in it. * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {}

2017-02-23 20:27:12 233

原创 Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.class Solution {public: ListNode* mergeKLists(vector<ListNode*>& lists) { if(lists.size()==

2017-02-23 20:20:12 300

原创 Merge Two Sorted Lists

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./** * Definition for singly-linked list. * struct ListNode

2017-02-23 19:49:39 220

原创 LeetCode(M) Sort List

Sort a linked list in O(n log n) time using constant space complexity.根据题目O(nlogn)时间,O(1)空间,选择了归并排序/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next;

2017-02-23 19:47:44 203

原创 LeetCode(M) Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->2

2017-02-23 11:12:43 287

原创 LeetCode(E) Remove Duplicates from Sorted List

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.最初我的代码ListNode *deleteDuplicates

2017-02-23 10:57:14 248

原创 LeetCode(M)threesum

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: The solution set must not contain duplic

2017-02-22 18:37:05 898

原创 lua的table类型

一、table类型概念 table类型是lua的核心概念,实现了“关联数组”,以key-value形式出现,以下我整理出table的要点,以及构建table时的要点。 1.table的key值类型可以是除nil外的任何类型,而value值类型可以是包括nil在内的任何类型 2.构建table时,key值要用“[“和”]”括住,比如 a={[2]=9} ,但是如果key是string型的话,可以

2017-01-28 21:41:15 1094

原创 大年三十,我又犯了哪些lua的错误

1. 2.for k,v in ipairs(a) do print(v) end k="y",v="c" -->此处报错,k,v相当于全局变量,又在泛型for中,不能再赋值

2017-01-27 11:43:25 281

原创 LintCode(S)二叉查找树插入节点

在二叉查找树中插入节点描述 笔记 数据 评测 给定一棵二叉查找树和一个新的树节点,将节点插入到树中。你需要保证该树仍然是一棵二叉查找树。您在真实的面试中是否遇到过这个题? Yes 样例 给出如下一棵二叉查找树,在插入节点6之后这棵二叉查找树可以是这样的:2 2 / \ / \ 1 4 –> 1 4 /

2017-01-03 09:20:52 382

原创 LintCode(M)带min函数的栈

带最小值操作的栈描述 笔记 数据 评测 实现一个带有取最小值min方法的栈,min方法将返回当前栈中的最小值。你实现的栈将支持push,pop 和 min 操作,所有操作要求都在O(1)时间内完成。注意事项如果堆栈中没有数字则不能进行min方法的调用您在真实的面试中是否遇到过这个题? 样例 如下操作:push(1),pop(),push(2),push(3),min(), pus

2016-12-21 15:53:50 310

原创 Lintcode(S)落单的数

落单的数描述 笔记 数据 评测 给出2*n + 1 个的数字,除其中一个数字之外其他每个数字均出现两次,找到这个数字。您在真实的面试中是否遇到过这个题? Yes 样例 给出 [1,2,2,1,3,4,3],返回 4挑战 一次遍历,常数级的额外空间复杂度标签 相关题目 解法一:class Solution {public: /** * @param A:

2016-12-21 11:15:28 270

原创 LintCode(M)三数之和

三数之和描述 笔记 数据 评测 给出一个有n个整数的数组S,在S中找到三个整数a, b, c,找到所有使得a + b + c = 0的三元组。注意事项在三元组(a, b, c),要求a <= b <= c。结果不能包含重复的三元组。您在真实的面试中是否遇到过这个题? Yes 样例 如S = {-1 0 1 2 -1 -4}, 你需要返回的三元组集合的是:(-1, 0, 1)(-1,

2016-12-21 09:29:09 508

原创 LintCode(M)两数之和

两数之和描述 笔记 数据 评测 给一个整数数组,找到两个数使得他们的和等于一个给定的数 target。你需要实现的函数twoSum需要返回这两个数的下标, 并且第一个下标小于第二个下标。注意这里下标的范围是 1 到 n,不是以 0 开头。注意事项你可以假设只有一组答案。您在真实的面试中是否遇到过这个题? Yes 样例 给出 numbers = [2, 7, 11, 15], tar

2016-12-20 20:46:36 479

原创 LintCode(M) 乱序字符串

乱序字符串描述 笔记 数据 评测 给出一个字符串数组S,找到其中所有的乱序字符串(Anagram)。如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中。注意事项所有的字符串都只包含小写字母您在真实的面试中是否遇到过这个题? Yes 样例 对于字符串数组 [“lint”,”intl”,”inlt”,”code”]返回 [“lint”,”inlt”,”i

2016-12-20 11:16:11 902

操作系统进程管理

里面包含操作系统的进程管理实验,里面含有核心代码以及实验心得等

2015-12-12

空空如也

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

TA关注的人

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