Left rotate an array to k places

Posted in Uncategorized by Administrator on the March 4th, 2018

package com.pnp.array.operations;

public class RorateArray {

public static int[] arrayLeftRotation(int[] nums, int n, int k) {
if(k > nums.length)

int[] result = new int[nums.length];
int j=0;
for(int i=k;i<nums.length;i++){

for(int i=0;i<k;i++){

return result;

public static void main(String[] args) {
int numbers[] = new int[]{1,2,3,4,5,6};
int k=4;//no. of places to rotate
int n=numbers.length;

int[] output = new int[n];

output = arrayLeftRotation(numbers, n, k);
for(int i = 0; i < n; i++)
System.out.print(output[i] + ” “);


/* Output:
* when k=3, output=4 5 6 1 2 3
* when k=4, output=5 6 1 2 3 4



Posted in Uncategorized by Administrator on the May 26th, 2014

“Decouple an abstraction from its implementation so that the two can vary independently” – by GoF.

Refund abstraction
Concrete Implementor

This has a

    abstract class

, an implementor.This abstract class has a reference to to this Interface(which is called implementor). This is a weak association as per UML.

Sample Page

Posted in Uncategorized by Administrator on the May 26th, 2014

This is an example page. It’s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:

Hi there! I’m a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)

…or something like this:

The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.

As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!

Hello world!

Posted in Uncategorized by Administrator on the May 26th, 2014

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!