摘要: 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. 题目要求: 给一有序链表,删除重复的结点,使得每个元素只出现一... 阅读全文
posted @ 2015-04-28 22:25 AndyJee 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 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 th... 阅读全文
posted @ 2015-04-28 21:46 AndyJee 阅读(890) 评论(1) 推荐(0) 编辑
摘要: 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: a... 阅读全文
posted @ 2015-04-28 21:10 AndyJee 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1、Given a linked list, determine if it has a cycle in it.2、Given a linked list, return the node where the cycle begins. If there is no cycle, return n... 阅读全文
posted @ 2015-04-28 20:45 AndyJee 阅读(801) 评论(0) 推荐(1) 编辑
摘要: 题目:假设张三的mp3里有1000首歌,现在希望设计一种随机算法来随机播放。与普通随机模式不同的是,张三希望每首歌被随机抽到的概率是与一首歌的豆瓣评分(0~10分)成正比的,如朴树的《平凡之路》评分为8.9分,逃跑计划的《夜空中最亮的星》评分为9.5分,则希望听《平凡之路》的概率与《夜空中最亮的星》... 阅读全文
posted @ 2015-04-28 17:47 AndyJee 阅读(2052) 评论(0) 推荐(0) 编辑
摘要: 题目:在一个N个整数数组里面,有多个奇数和偶数,设计一个排序算法,令所有的奇数都在左边。请完成sort的代码实现(C++或Java)C++:void sort(int N, int[]a){ …}例如: 当输入a = {8,4,1,6,7,4,9,6,4},a = {1,7,9,8,4,6,4,6... 阅读全文
posted @ 2015-04-28 15:18 AndyJee 阅读(3998) 评论(0) 推荐(0) 编辑
摘要: 题目:给定一个字符串,请写一段代码找出这个字符串中首先出现两次的那个字符。 例如字符串为"qywyer23tdd",输出为y。思路:1、从头到尾遍历字符串str,如果str[i]为首先出现两次的字符,则满足的条件是str[i]==str[j](0<=j<i);2、遍历字符串时,通过类似hash数组来... 阅读全文
posted @ 2015-04-28 13:21 AndyJee 阅读(724) 评论(0) 推荐(0) 编辑
摘要: 题目:以下关于头文件,说法正确的是(B)A、#include,编译器寻找头文件时,会从当前编译的源文件所在的目录去找B、#include“filename.h”,编译器寻找头文件时,会从通过编译选项指定的目录去找C、多个源文件同时用到的全局整数变量,它的声明和定义都放在头文件中,是好的编程习惯D、在... 阅读全文
posted @ 2015-04-28 12:44 AndyJee 阅读(737) 评论(0) 推荐(0) 编辑
摘要: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 –> 5 题目要求: 删除链表中包含val的元素结点 解题思路: 重点在于找到... 阅读全文
posted @ 2015-04-28 00:13 AndyJee 阅读(432) 评论(0) 推荐(0) 编辑