Skip to content

Instantly share code, notes, and snippets.

View govi20's full-sized avatar
:atom:
Trapped in a machine

Govinda Sakhare govi20

:atom:
Trapped in a machine
View GitHub Profile
@govi20
govi20 / Jackson Deserialization
Last active January 10, 2021 06:14
Jackson Backward Compatibility while changing Array type to Object
// Below two string are created using two different models: Refer below two files to track the changes between models
String oldString = "{\"id\":1,\"addresses\":[{\"addressLine1\":\"Central Park\",\"city\":\"NYC\",\"country\":\"UK\"},{\"addressLine1\":\"Near Wembley\",\"city\":\"London\",\"country\":\"UK\"}]}";
String newString = "{\"id\":1,\"addressDetails\":{\"addressInfos\":[{\"addressLine1\":\"Central Park\",\"city\":\"London\",\"country\":\"UK\"},{\"addressLine1\":\"Near Wembley\",\"city\":\"London\",\"country\":\"UK\"}]}}";
ObjectMapper objectMapper = new ObjectMapper();
try {
Person person1 = objectMapper.readValue(oldString, Person.class);
Person person2 = objectMapper.readValue(newString, Person.class);
System.out.println(person1);
System.out.println(person2);
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
/* Merge sort in C */
#include<stdio.h>
#include<stdlib.h>
// Function to Merge Arrays L and R into A.
// lefCount = number of elements in L
// rightCount = number of elements in R.
void Merge(int *A,int *L,int leftCount,int *R,int rightCount) {
int i,j,k;
/* Merge sort in C */
#include<stdio.h>
#include<stdlib.h>
// Function to Merge Arrays L and R into A.
// lefCount = number of elements in L
// rightCount = number of elements in R.
void Merge(int *A,int *L,int leftCount,int *R,int rightCount) {
int i,j,k;
#include<cmath>
#include<iostream>
#include<climits>
using namespace std;
int Maximum_Sum_Subarray(int arr[],int n) //Overall Time Complexity O(n^2)
{
int ans = INT_MIN;
for(int start_index = 0;start_index < n; ++start_index) //O(n)
{