青蛙跳跳: package com.code; public class Test03_1 { public int solution(int X, int Y, int D) { int res = (Y-X)/D+((Y-X)%D==0?0:1); return res; } public static void main(String[] args) { Test03_1 t03 = new Test03_1(); System.out.println(t03.solution(10, 8…
Count the number of occurrences in a sorted array Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[]. Expected time complexity is O(Logn) Examples: Input: arr[] = {1, 1, 2, 2, 2, 2, 3,}, x = 2 Output…
If you want to see the number of threads per process in Linux environments, there are several ways to do it. Method One: /proc The proc pseudo filesystem, which resides in /proc directory, is the easiest way to see the thread count of any active proc…
Description Given n numbers, your task is to insert '+' or '-' in front of each number to construct expressions. Note that the position of numbers can be also changed. You can calculate a result for each expression. Please count the number of distinc…
From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of positive integers. Find the number of triangles that can be formed with three different array elements as three sides of triangles. For a triangle to be…
有时候在项目中我们需要检测当前连接在机子上的摄像头的数量,可以通过下面的代码实现,其中连接摄像头的最大数量maxCamNum可以任意修改: /** * Count current camera number */ int countCamera() { ; ; ; device < maxCamNum; device++) { CvCapture* capture; if (_capture[device]) { ++count; } else { capture = cvCaptureFrom…
[error]C1003: error count exceeds 100; stopping compilation ...winnt.h 在项目工程中添加#include<windows.h>之后出现如下问题: Error 110 error C1003: error count exceeds 100; stopping compilation C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h 1355…
给一个超级大的排好序的vector [abbcccdddeeee]比如,要求返回[{,a}, {,b}, {,c}, {,d}, {,e}......]复杂度要优于O(N) 分析: 如果是binary search找每个char的上下界,worst case要找n次,时间复杂度O(nlogn) 所以考虑每次比较start point和start point + 2^n位置上的数,假如一样就continue,不一样就在区间里面binary search找上界,这样worst case O(N) p…
源头  出现这个报错提示,大家从错误就可以看的出来,这就是json的错误,一般来说都是json格式出现了错误,本人遇到比较多的情况就是json字符串里面出现了一些会影响json格式的符号,这次出现这个错误的原因就是json字符串里面出现了引号. 事发–血案  今天客户让我查询一个合同,但是打开合同具体信息时发现合同页面里面都是空白,自然而然就用浏览器调试,发现了这个错.      遇到这种问题没办法了,只能检查把自己的json字符串显示出来查看看是否存在特别的字符,一般来说像反斜杠,单引号,双引…
lesson 3: Time complexity exercise: Problem: You are given an integer n. Count the total of 1+2+...+n. def sumN(N): return N*(N+1)//2 1. TapeEquilibrium -----[100%] Minimize the value |(A[0] + ... + A[P-1]) - (A[P] + ... + A[N-1])|. A non-empty zero-…