Featured Article

Subarray/Substring vs Subsequence and Programs to Generate them

Subarray/Substring A subbarray is a contiguous part of array. An array that is inside another array. For example, consider the array [1, 2, 3, 4], There are 10 non-empty sub-arrays. The subbarays are (1), (2), (3), (4), (1,2), (2,3), (3,4), (1,2,3), (2,3,4) and (1,2,3,4). In general, for an array/string of size n, there are n*(n+1)/2… Read More »

Featured Article

Array vs ArrayList in Java

In Java, following are two different ways to create an array. Array: Simple fixed sized arrays that we create in Java, like below int arr[] = new int[10] ArrayList : Dynamic sized arrays in Java that implement List interface. ArrayList<Type> arrL = new ArrayList<Type>(); Here Type is the type of elements in ArrayList to be… Read More »

Featured Article

1’s and 2’s complement of a Binary Number

Given a Binary Number as string, print its 1’s and 2’s complements. 1’s complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0. Examples: 1’s complement of “0111” is “1000” 1’s complement of “1100” is “0011”… Read More »

Featured Article

Longest Zig-Zag Subsequence

The longest Zig-Zag subsequence problem is to find length of the longest subsequence of given sequence such that all elements of this are alternating. If a sequence {x1, x2, .. xn} is alternating sequence then its element satisfy one of the following relation : x1 < x2 > x3 < x4 > x5 < ….… Read More »

Featured Article

Array Copy in Java

Given an array, we need to copy its elements in a different array. Method 1 (Simple but Wrong) We might be tempted to proceed like this: However it’s incorrect! When we do “b = a”, we actually assigning reference of array. Hence if we make any change to one array, it would be reflected in… Read More »

Featured Article

Submatrix Sum Queries

Given a matrix of size M x N, there are large number of queries to find submatrix sums. Inputs to queries are left top and right bottom indexes of submatrix whose sum is to find out. How to preprocess the matrix so that submatrix sum queries can be performed in O(1) time. Example: tli :… Read More »

Oracle Interview Experience | Set 22 (On-Campus for Oracle Financial Services Software)

Written round: There were questions related to quantitative,logical and verbal.(Not of very high level,but speed should be good enough). Technical PI: 1. C:Basic topics of C.Malloc and Clloc difference.Storage classes.Let us C is enough . 2. C++/Java: OOPs concept with real life examples,Collection in Java,Constructors etc . Site i referred: JAVATPOINT 3. DBMS: Explain normalization… Read More »

Jagged Array in Java

Jagged array is array of arrays such that member arrays can be of different sizes, i.e., we can create a 2-D arrays but with variable number of columns in each row. These type of arrays are also known as ragged arrays. Following are Java programs to demonstrate the above concept. Output: Contents of 2D Jagged… Read More »

Bootstrap (Part- 4)

BootStrap 1 BootStrap 2 BootStrap 3 After the previous article, you should be familiar with the basics of Bootstrap. So, in this article, we’ll learn creating forms. Forms are used almost in every website and they are used to collect user input. Forms: Bootstrap provides 3 types of form layout, namely: Vertical Forms (Default) Horizontal… Read More »

How to avoid overflow in modular multiplication?

Consider below simple method to multiply two numbers. The above function works fine when multiplication doesn’t result in overflow. But if input numbers are such that the result of multiplication is more than maximum limit. For example, the above method fails when mod = 1011, a = 9223372036854775807 (largest long long int) and b =… Read More »

Form minimum number from given sequence

Given a pattern containing only I’s and D’s. I for increasing and D for decreasing. Devise an algorithm to print the minimum number following that pattern. Digits from 1-9 and digits can’t repeat. Examples: Input: D Output: 21 Input: I Output: 12 Input: DD Output: 321 Input: II Output: 123 Input: DIDI Output: 21435 Input:… Read More »

Interesting facts about strings in Python | Set 1

1. Strings are Immutable Once a string is defined, it cannot be changed. Output: Traceback (most recent call last): line 3, in a[2] = ‘E’ TypeError: ‘str’ object does not support item assignment But below code works fine. Output: Geeks Geeksfor In the second program, interpreter makes a copy of the original string and then… Read More »