CC150 - 11.5】的更多相关文章

Question: Given an M x N matrix in which each row and each column is sorted in ascending order, write a method to find an element. package POJ; public class Main { /** * * 11.6 Given an M x N matrix in which each row and each column is sorted in * as…
Question: Given a sorted array of strings which is interspersed with empty strings, write a method to find the location of a given string. package POJ; public class Main { /** * * 11.5 Given a sorted array of strings which is interspersed with empty…
Question: Given a sorted array of n integers that has been rotated an unknown number of times, write code to find an element in the array. You may assume that the array was originally sorted in increasing order. package POJ; import java.util.Arrays;…
Question: Write a method to sort an array of strings so that all the anagrams are next to each other. package POJ; import java.util.Arrays; import java.util.Comparator; import java.util.Hashtable; import java.util.LinkedList; import java.util.List; p…
Question: You are given two sorted arrays, A and B, where A has a large enough buffer at the end to hold B.Write a method to merge B into A in sorted order. package POJ; public class Main { /** * * 11.1 You are given two sorted arrays, A and B, where…
/*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : localhost:3306Source Database : ben500_info Target Server Type : MYSQLTarget Server Version : 50136File Encoding : 65001 Date: 2013-07-11 10:07:33*/ SET…
思路:比较easy.就是借助hashset让他有序然后就能够比较节省时间了. 答案: public static int[] getRankOfNumber(int[] a, int n){ int[] res = new int[n]; HashSet<Integer> hash = new HashSet(); for(int i = 0; i < n;i++){ int num = 0; for(int tmp : hash){ if(tmp <= a[i]){ num++;…
1,牛客网第一题:这其实跟找最长递增子序列是一个东西.注意的地方是,返回的是最大的dp,而不是dp[N-1]. 答案: public static int getHeight(int[] men, int n) { // write code here int res = 0; int[] dp = new int[n]; dp[0] = 1; for(int i =1;i <n;i++){ int max = 0; for(int j =0;j < i;j++){ if(men[j] <…
思路,一旦提到查找就要想到二分查找. public static int[] findElement(int[][] a, int n, int m, int key) { // write code here int[] res = new int[2]; for(int i = 0;i < n;i++){ int left = 0; int right = m - 1; while(left <= right){ int mid = (left + right) / 2; if(key &…
注意,1,"" 和 " ".是不同的,空字符串指的是"": 2,注意String的compareTo.小于是指<0.并不是==-1: 仔细观察代码中注释掉的那一行错在哪里. import java.util.*; public class Finder { public static int findString(String[] a,int n, String key){ int left = 0; int right = a.lengt…
思路,这道题用二分,唯一的不同就是,1,a[left]<a[mid].那么说明左右有序,如果key还在a[left],a[mid]之间,就在这里找,如果不在就在右边找.注意:这里<要改成<=才对. 2,如果不是条件一,那么就是右边有序,看key是否在mid和right之间,在的话这个范围找,不在的话,左边找. 答案: public static int findElement(int[] a, int n,int key){ int left = 0; int right = a.len…
这道题主义的就是,要利用数组自带的sort函数. 此外,注意,利用hash来判断是否出现了. public static ArrayList<String> sortStrings(String[] str, int n) { // write code here ArrayList<String> res = new ArrayList(); //sort Arrays.sort(str); HashSet<String> hash = new HashSet();…
这道题比较简单,就是通过从后往前复制大的就可以了.最后比较注意的就是如果B还没复制完要记得接着复制. import java.util.Arrays; public class Solution{ public static void main(String[] args){ int[] a = {2,4,5,0,0,0}; int[] b = {1,3,6}; merge(a,b,3,3); System.out.println(Arrays.toString(a)); } public st…
第18章---高度难题 1,-------另类加法.实现加法. 另类加法 参与人数:327时间限制:3秒空间限制:32768K 算法知识视频讲解 题目描述 请编写一个函数,将两个数字相加.不得使用+或其他算数运算符. 给定两个int A和B.请返回A+B的值 测试样例: 1,2 返回:3 答案和思路:xor是相加不进位.and得到每一个地方的进位.所以,用and<<1之后去与xor异或.不断递归. import java.util.*; public class UnusualAdd { pu…
面试题17.1:编写一个函数,不用临时变量,直接交换两个数. 思路:使用差值或者异或 package cc150.middle; public class Exchange { public static void main(String[] args) { // TODO 自动生成的方法存根 int[] a= {1,2}; Exchange ec = new Exchange(); int[] b= ec.exchangeAB(a); System.out.println(b[0]); Sys…
面试题11.1:给定两个排序后的数组A和B,其中A的末端有足够的缓冲空间容纳B.编写一个方法,将B合并入A并排序. package cc150.sort_search; public class MergeTwoSortedArr { public static void main(String[] args) { // TODO 自动生成的方法存根 int[] a = {1,3,5,7,9,11,13,15,0,0,0,0,0,0,0,0}; int[] b = {0,2,4,6,8,10,1…
面试题3.1:描述如何只用一个数组来实现三个栈. 方法1:固定分割 方法2:弹性分割(较难) package cc150; public class ArrayStack { public static void main(String[] args) throws Exception { // TODO 自动生成的方法存根 ArrayStack theStack = new ArrayStack(); theStack.push(0, 1); theStack.push(0, 2); theS…
1,自己写的又长又臭的代码,也能AC,但是太丑了.主要是通过二进制来算. public static int addAB(int a, int b){ int res = 0; String str1 = Integer.toBinaryString(a); String str2 = Integer.toBinaryString(b); ArrayList<Integer> list = new ArrayList(); int digit = 0; int cur = 0; int i =…
1. 正确获取红包流程 2. 软件介绍 2.1 效果图: 2.2 功能介绍 2.2.1 账号登录 页面开始时,会载入这个网站:https://login.taobao.com/member/login.jhtml?redirect_url=http%3A%2F%2F1111.tmall.com%2F 登录成功后,会自动跳转到1111.tmall.com活动页面. 2.2.2 [去抽奖]按钮 这按钮是手动跳转到1111.tmall.com页面 2.2.3 [开始狂欢]按钮 隐藏活动界面的载入Div…
#include <iostream> using namespace std; int main() { using cullptr = const unsigned long long *; //C++11新变量类型long long;constexpr unsigned long long * 为非法 typedef wchar_t * wchptr; /* 使用using或typedef声明的类型别名的变量实例初始化时,不同类型变量不可使用","写在同一行 如://…
今天是邓呆呆球衣退役的日子,在这个颇具纪念意义的日子里我写下自己的第一篇博客,还望前辈们多多提携,多多指教! 接下来,就进入正文,来说说关于垂直居中的事.(以下这11种垂直居中的实现方式均为笔者在日常的开发过程中总结得到,如发现和您的观点确有雷同之处,那么实在荣幸能和前辈们英雄所见略同!) 另:这里的demo都只是针对现代浏览器所做,未兼容低版本的IE以及其它非主流浏览器. 11种实现方式分别如下: 1. 使用绝对定位和负外边距对块级元素进行垂直居中 html代码: <div id="bo…
说到多线程编程,那么就不得不提并行和并发,多线程是实现并发(并行)的一种手段.并行是指两个或多个独立的操作同时进行.注意这里是同时进行,区别于并发,在一个时间段内执行多个操作.在单核时代,多个线程是并发的,在一个时间段内轮流执行:在多核时代,多个线程可以实现真正的并行,在多核上真正独立的并行执行.例如现在常见的4核4线程可以并行4个线程:4核8线程则使用了超线程技术,把一个物理核模拟为2个逻辑核心,可以并行8个线程. 并发编程的方法 通常,要实现并发有两种方法:多进程和多线程. 多进程并发 使用…
CSharpGL(11)用C#直接编写GLSL程序 +BIT祝威+悄悄在此留下版了个权的信息说: 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharpGL源码中包含10多个独立的Demo,更适合入门参考. 为了尽可能提升渲染效率,CSharpGL是面向Shader的,因此稍有难度. 由来 本项目的目的:使开发者可以直接用C#书写GLSL代码. 现在(2016年1月30日)编写GLSL的shader程序时,并没有什么好的开发环境.智能提示.代码补全…
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之11.ABP领域层——仓储(Repositories) ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)”的简称. ABP的官方网站:http://www.aspnetboilerplate.com ABP在Github上的开源项目:https://github.com/aspnetboilerplate 本文由台湾-小张提供翻译 仓储定义:“在领域层和数据映射层的中…
多线程程序经常会遇到在某个线程A创建了一个对象,这个对象需要在线程B使用, 在没有shared_ptr时,因为线程A,B结束时间不确定,即在A或B线程先释放这个对象都有可能造成另一个线程崩溃, 所以为了省时间一般都是任由这个内存泄漏发生. 当然也可以经过复杂的设计,由一个监控线程来统一删除, 但这样会增加代码量和复杂度.这下好了,shared_ptr 可以方便的解决问题,因为它是引用计数和线程安全的. shared_ptr不用手动去释放资源,它会智能地在合适的时候去自动释放. 我们来测试看看效果…
Handy是一个简洁优雅的C++11网络库,适用于linux与Mac平台.十行代码即可完成一个完整的网络服务器. 下面是echo服务器的代码: #include <handy/handy.h> using namespace std; using namespace handy; int main(int argc, const char* argv[]) { EventBase bases; //事件分发器 Signal::signal(SIGINT, [&]{ bases.exit…
系列目录 系统需要越来越自动化,我们需要引入日志记录和异常捕获管理员的操作记录需要被记录,看出哪些模块是频繁操作,分析哪些是不必要的功能,哪些是需要被优化的.系统的异常需要被捕获,而不是将系统出错显示出来给用户就不了了知.我们需要异常日志不断改进系统.我们老说用户,我们还没有用户权限的表,所以我们在Home中先加入一个虚拟用户吧! 首先我们创建一个用户类AccountModel放在App.Models下的Sys文件夹下 using System; using System.Collections…
本文记录了打PSU的全过程,意在体会数据库打PSU补丁的整个过程. 1.OPatch替换为最新版本2.数据库软件应用19121551补丁程序3.数据库应用补丁4.验证PSU补丁是否应用成功 1.OPatch替换为最新版本 [oracle@DB usr2]$ id uid=(oracle) gid=(oinstall) 组=(oinstall),(dba) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [oracle@DB usr…
写在前面: 1.Oracel打每个补丁的操作有时存在差异,所以不管多熟悉,都应该在打任何补丁之前阅读新补丁中附带的readme. 2.Oracle每季度都会更新一个最新的PSU,本文最新指的是当前最新(即0719发布的PSU). 3.之前整理的完整记录一则Oracle 11.2.0.4单实例打PSU补丁的过程由于旨在体验打补丁的整个过程,粘贴了所有过程输出,篇幅很长,不利于快速参考,本次旨在可以用来快速参考,并增加了OJVM PSU的修补部分.如果对本文的简要命令有疑问,可以反过来参考之前的文…
环境:两节点RAC(RHEL 6.4 + GI 11.2.0.4 + Oracle 11.2.0.4) 需求:安装最新PSU补丁11.2.0.4.7 1.下载补丁和最新OPatch 2.检查数据库当前OPatch版本 3.更新OPatch 4.解压补丁文件 5.检查补丁之间有无冲突 6.停止数据库和本地crs服务 7.更新补丁 8.登录数据库执行升级字典操作 9.验证补丁更新结果 Reference 1. 下载补丁和最新OPatch MOS 补丁程序和更新程序搜索到最新的PSU:截至目前最新是1…