Amazon OA
Remove Duplicates from unsorted array,它的错误在于9-10行k out of bound,改成下面这样就没问题了
public class removeDuplicates {
public static int[] remove(int[] arr){
int end = arr.length;
for(int i = 0; i < end; i++){
for(int j = i + 1; j < end; j++){
if(arr[i] == arr[j]){
for(int k = j+1; k < end; k++){
arr[k-1] = arr[k];
}
end--;
j--;
}
}
}
int[] whitelist = new int[end];
for(int i = 0; i < end; i++){
whitelist[i] = arr[i];
}
System.out.print("new length is ");
System.out.println(end);
return whitelist;
}
public static void main(String[] args) {
int[] arr = {3, 2, 1, 3, 2, 1, 3, 2, 1};
remove(arr);
for(int i:arr){
System.out.print(i);
System.out.print(", ");
}
}
}
Selection Sort Ascending order, 它的错误在于7行大于小于错误
public static int[] doSelectionSort(int[] arr){
for (int i = 0; i < arr.length-1; i++)
{
int index = i;
for (int j = i + 1; j < arr.length; j++)
if (arr[j] < arr[index])
index = j;
int smallerNumber = arr[index];
arr[index] = arr[i];
arr[i] = smallerNumber;
}
return arr;
}
Selection Sort Dscending order, 他的错误在于第5行大于小于错误
public static int[] doSelectionSort(int[] arr){
for (int i=0; i<arr.length-1; i++) {
int max = i;
for (int j=1; j<arr.length; j++) {
if (max < arr[j]) {
max = j;
}
}
if (max != i) {
int temp = arr[i];
arr[i] = arr[max];
arr[max] = temp;
}
}
return arr;
}
Reverse an int array, 它的问题在于第3行忘了-1
for (int i=0; i<arr.length/2; i++) {
int temp = arr[i];
arr[i] = arr[arr.length-1-i];
arr[arr.length-1-i] = temp;
}
Print Pattern, 打印11, 1111, 111111,中间需要换行,它的问题在于括号少打了
Amazon OA的更多相关文章
- Amazon | OA 2019 | Optimal Utilization
Given 2 lists a and b. Each element is a pair of integers where the first integer represents the uni ...
- 标准产品+定制开发:专注打造企业OA、智慧政务云平台——山东森普软件,交付率最高的技术型软件公司
一.公司简介山东森普信息技术有限公司(以下简称森普软件)是一家专门致力于移动互联网产品.企业管理软件定制开发的技术型企业.公司总部设在全国五大软件园之一的济南齐鲁软件园.森普SimPro是由Simpl ...
- 港真,到底应该选择OA还是BPM?
越来越多企业意识到流程管理的重要性,但是,选择OA还是BPM,却让他们产生了选择困难症. 一方面,企业皆注重流程的高效运转,最好内外部的业务都能用一个系统来解决.所有流程一天就能上线什么的,那就更好啦 ...
- 从零到有——我的OA如何成长
早前发文说要分享,马上进入了财务系统的开发,拖到现在,见笑了. 我在月初离职了,所以到处跑,找工作,想想南京.苏州.无锡(去玩的).杭州(路过).上海.珠海.深圳.广州.觉得找工作也差不多尾声了,就留 ...
- 网络爬虫: 从allitebooks.com抓取书籍信息并从amazon.com抓取价格(3): 抓取amazon.com价格
通过上一篇随笔的处理,我们已经拿到了书的书名和ISBN码.(网络爬虫: 从allitebooks.com抓取书籍信息并从amazon.com抓取价格(2): 抓取allitebooks.com书籍信息 ...
- 网络爬虫: 从allitebooks.com抓取书籍信息并从amazon.com抓取价格(2): 抓取allitebooks.com书籍信息及ISBN码
这一篇首先从allitebooks.com里抓取书籍列表的书籍信息和每本书对应的ISBN码. 一.分析需求和网站结构 allitebooks.com这个网站的结构很简单,分页+书籍列表+书籍详情页. ...
- 网络爬虫: 从allitebooks.com抓取书籍信息并从amazon.com抓取价格(1): 基础知识Beautiful Soup
开始学习网络数据挖掘方面的知识,首先从Beautiful Soup入手(Beautiful Soup是一个Python库,功能是从HTML和XML中解析数据),打算以三篇博文纪录学习Beautiful ...
- OA办公自动化系统源码
最新extjs6富客户端,.net平台开发,sql server数据库,基础权限人员基础平台,可方便二次开发,使用EF为orm,autofac为ioc,Castle为基础的aop,实现常用OA系统功能 ...
- Amazon Interview | Set 27
Amazon Interview | Set 27 Hi, I was recently interviewed for SDE1 position for Amazon and got select ...
随机推荐
- PKI技术原理
转:http://3layer.blog.51cto.com/57448/20430 对称加密 symmetric cryptographic 非对称加密 asymmetric ...
- Redis学习笔记--Redis配置文件redis.conf参数配置详解
########################################## 常规 ########################################## daemonize n ...
- Panel结构
参考weui的Panel结构 核心:定位,补充:对容器设置font-size:0,消除img下多出的3px,防止居中出现偏差. <!DOCTYPE html> <html lang= ...
- 题目1002:Grading(题目背景基于高考打分的简单判断)
题目链接:http://ac.jobdu.com/problem.php?pid=1002 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- Protobuf的安装使用
date: 2018-10-12 18:59:13 版权归属原作者,本位转自:https://www.cnblogs.com/autyinjing/p/6495103.html 1. 是什么? Go ...
- 如何使用Gradle的maven-publish将jar包或者war包上传到nexus仓库
首先,在build.gradle里边声明依赖maven-publish插件: apply plugin: 'maven-publish' 然后,配置项目的信息和和nexus的信息: publishin ...
- matlab 获取网卡MAC地址
输入命令 [sta,MACres] = dos('getmac'); 其中MACres 存储的信息即为网卡的 相关信息. 如果想判断读取的网卡信息是否有指定信息可以如下输入 USER1 = strf ...
- eclipse使用maven打包时去掉测试类
eclipse使用maven打包时去掉测试类 在pom.xml文件中增加如下配置: <plugin> <groupId>org.apache.maven.plugins< ...
- 7.18python进程池
主要方法 常用的就是 from multiprocessing import Pool map() 同步 apply() 同步 apply_async() 异步 手动 close() jo ...
- css实现表格的td里面的内容居中.
<td align="center" valign="middle">前一个是水平居中 后一个是垂直居中对应的css写法:<td style= ...