public int[] fix34(int[] nums) {

  int i3=0;
int i4=0;
int temp=0; while( (i3<nums.length)&&(i4<nums.length))
{
while(i3<nums.length){
if(nums[i3]==3) break;
i3++;
} while(i4<nums.length){
if(nums[i4]==4) break;
i4++;
} if(i3 < nums.length-1){
temp=nums[i4];
nums[i4]=nums[i3+1];
nums[i3+1]=temp;
i3++;
i4++; } }
return nums;
}

http://codingbat.com/prob/p159339

fix34的更多相关文章

随机推荐

  1. 概念:RPG游戏中两个兵种互相攻击的逻辑

    直接上题目: 解析题目: 根据题目的解析,进行代码的实现: 输出结果: 心得: (1) 当我们面对‘公式结果不是我们想要的’时,应该在脑海里将一个完整的攻击流程进行想象,就会对流程有个更清晰的思路 ( ...

  2. CRM WebClient UI和Hybris里工作中心跳转的url生成逻辑

    CRM WebClient UI 把Work center的navigation target在client side不可见:在Chrome development tool里看不到,而是点击了Wor ...

  3. Association, Composition and Aggregation in UI5, CRM, S/4HANA and C4C

    UI5 UI5使用Association和Aggregation描述控件之间的关系. Aggregation:parent和子控件在lifecycle上存在依赖关系: When a ManagedOb ...

  4. IOS tableView的基本使用

    tableView  Style:Plain(头部标题 向上移 不会消失) tableView  Style:Grouped(头部标题 向上移 会 消失) #import "ViewCont ...

  5. linux 内存地址空间管理 mm_struct

    http://blog.csdn.net/yusiguyuan/article/details/39520933 Linux对于内存的管理涉及到非常多的方面,这篇文章首先从对进程虚拟地址空间的管理说起 ...

  6. A. Round House_数学问题

    A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  7. 【转】Android开发学习笔记(一)——初识Android

    对于一名程序员来说,“自顶向下”虽然是一种最普通不过的分析问题和解决问题的方式,但其却是简单且较为有效的一种.所以,将其应用到Android的学习中来,不至于将自己的冲动演变为一种盲目和不知所措. 根 ...

  8. 下载Xcode历史版本方法

    1.打开链接:https://developer.apple.com/download/more 进入页面 2.在搜索框输入Xcode,回车搜索.如图,找到各种版本Xcode 搜索Xcode 3.双击 ...

  9. test image

    Most of these images are in PBM or PGM format and compressed with GNU Zip and GNU TAR Note: These pa ...

  10. MySQL 存储过程参数IN OUT INOUT区别

    MySQL 存储过程参数IN OUT INOUT对比 一.IN -- 创建测试存储过程 delimiter // create procedure p_in ( IN num int ) begin ...