Skip to content

Instantly share code, notes, and snippets.

View hiteshchopra11's full-sized avatar

Hitesh Chopra hiteshchopra11

View GitHub Profile
@hiteshchopra11
hiteshchopra11 / duplicate_sorting.cpp
Created February 24, 2021 16:05
Find duplicate element using Sorting approach
#include <bits/stdc++.h>
using namespace std;
int sorting_duplicate(int arr[], int n)
{
//Sort the array using STL sort function or write own sorting algorithm(merge sort or heap sort)
sort(arr, arr + n);
for (int i = 1; i < n; i++)
{
//As the list is sorted,if two consecutive values are found, return the value as it is duplicate
@hiteshchopra11
hiteshchopra11 / duplicate_hashing.cpp
Last active February 24, 2021 19:53
Duplicate number using hashing
#include <bits./stdc++.h>
using namespace std;
int duplicate_hashing(int arr[], int n)
{
//Create a boolean value of size n
bool flag[n];
//Set all values of flag boolean array initially as false
fill(flag, flag + n, false);
{ "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
routing {
get("/notes") {
val notes = arraylistof("Note 1","Note 2")
call.respond(notes)
}
}
insert into t_note (id,note) values (?, ?)
database.insert(Notes) {
 set(it.id, "id")
 set(it.note, "note")
}
@Serializable
data class NoteRequest(val note: String)
val request = call.receive<NoteRequest>()
val result = db.insert(NotesEntity) {
set(it.note, request.note)
}
@Serializable
data class NoteResponse<T>(
val data: T,
val success: Boolean
)
get("/notes") {
val notes = db.from(NotesResponse).select().map {
val id = it[NotesEntity.id]
val note = it[NotesEntity.note]
Note(id ?: -1, note ?: "")
}
// Returns the response to the User
call.respond(notes)
}