View transaction_dinesh.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- create | |
CREATE TABLE TRANSACTION ( | |
id INTEGER NOT NULL, | |
TRANS VARCHAR(3) NOT NULL, | |
CODE INTEGER NOT NULL | |
); | |
-- insert | |
INSERT INTO TRANSACTION VALUES (1001, 'TE', 9000); | |
INSERT INTO TRANSACTION VALUES (1002, 'TE', 9000); |
View PoliceHacker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package thread.creation; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
public class PoliceHacker { | |
public static final int MAX_PASSWORD = 24999; |
View LC1904.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
private int getStartMinuteRoundUp(int min) { | |
if (min % 15 == 0) return min; | |
if (min > 0 && min < 15) return 15; | |
if (min > 15 && min < 30) return 30; | |
if (min > 30 && min < 45) return 45; | |
return 0; | |
} | |
private int getFinishMinuteRoundUp(int min) { |
View RearrangeCharacters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public static String rearrangeCharacters(String str) { | |
Map<Character, Integer> freq = new HashMap<>(); | |
for (char c : str.toCharArray()) freq.put(c, freq.getOrDefault(c, 0) + 1); | |
List<Map.Entry<Character, Integer>> freqList = new ArrayList<>(freq.entrySet()); | |
// freqList.sort(Map.Entry.comparingByValue()); | |
freqList.sort((e1, e2) -> e2.getValue() - e1.getValue()); | |
Map<Character, Integer> sortedFreq = new LinkedHashMap<>(); | |
for (Map.Entry<Character, Integer> entry : freqList) sortedFreq.put(entry.getKey(), entry.getValue()); | |
int n = str.length(); |
View NextGreaterElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution{ | |
public static long[] nextLargerElement(long[] arr, int n) { | |
Stack<Integer> stack = new Stack<>(); | |
stack.push(0); | |
long[] result = new long[n]; | |
Arrays.fill(result, -1); | |
for (int i = 1; i < n; ++i) { | |
while (!stack.isEmpty() && arr[i] > arr[stack.peek()]) { | |
result[stack.pop()] = arr[i]; | |
} |
View indianCurrencyFormatter.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(void) { | |
int len,i; | |
char str[100]; | |
gets(str); | |
len = strlen(str); | |
if (len < 3) { | |
printf("%s",str); |
View Guessing_Game_Two.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search(first,last,count): | |
guess=int((first+last)/2) | |
print (guess) | |
opt=int(input()) | |
if opt==1: | |
print ("Count: "+str(count)) | |
print ("Correct guess") | |
elif opt==2: | |
print ("Count: "+str(count)) | |
binary_search(first,guess,count+1) |
View RockPaperScissor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
a=input("Player1: ",) | |
b=input("Player2: ",) | |
if a=='rock': | |
if b=='paper': | |
print ("Congragulations ! Player2 won") | |
elif b=='scissor': | |
print ("Congragulations ! Player1 won") | |
else: | |
print ("Draw") |