This file contains hidden or 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
import org.springframework.context.ApplicationContext; | |
import org.springframework.context.support.ClassPathXmlApplicationContext; | |
public class ApplicationContextExam01 { | |
public static void main(String[] args) { | |
ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:applicationContext.xml"); | |
// instantiate beans below |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
https://www.springframework.org/schema/beans/spring-beans.xsd"> | |
<bean id="..." class="..."> | |
<!-- collaborators and configuration for this bean go here --> | |
</bean> |
This file contains hidden or 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 Person{ | |
int[] friends; | |
List<String> videos; | |
Person(int[] friends){ | |
this.friends = friends; | |
} | |
} | |
class Solution { | |
public List<String> watchedVideosByFriends(List<List<String>> watchedVideos, int[][] friends, int id, int level) { |
This file contains hidden or 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 int minSwapsCouples(int[] row) { | |
int num = 0, temp = 0, cnt=0; | |
for (int i=0;i<row.length;i++) { | |
num=row[i]%2==0?row[i]+1:row[i]-1; | |
if (row[++i] == num) continue; | |
for(int j=i;j<row.length;j++) { | |
if (row[j] == num) { | |
temp = row[i]; |
This file contains hidden or 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
/* | |
https://leetcode.com/problems/string-without-aaa-or-bbb/ | |
*/ | |
class Solution { | |
public String strWithout3a3b(int a, int b) { | |
StringBuilder sb = new StringBuilder(); | |
char ch; | |
int acnt=0,bcnt=0; |
This file contains hidden or 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
/* | |
https://leetcode.com/problems/car-pooling/ | |
*/ | |
class Solution { | |
public boolean carPooling(int[][] trips, int capacity) { | |
int[] pick = new int[1001], drop = new int[1001]; | |
for(int i=0;i<trips.length;i++) { | |
pick[trips[i][1]]+=trips[i][0]; |
This file contains hidden or 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
/* | |
https://leetcode.com/problems/lemonade-change/ | |
*/ | |
class Solution { | |
public boolean lemonadeChange(int[] bills) { | |
int c1=0,c2=0,c3=0; | |
boolean flag = true; | |
This file contains hidden or 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
public class ConnectingIsland { | |
static class Edge implements Comparable<Edge> { | |
int from; | |
int to; | |
int cost; | |
public Edge(int from, int to, int cost) { | |
super(); | |
this.from = from; | |
this.to = to; |
This file contains hidden or 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
KRUSKAL(G): | |
A = β | |
For each vertex v β G.V: | |
MAKE-SET(v) | |
For each edge (u, v) β G.E ordered by increasing order by weight(u, v): | |
if FIND-SET(u) β FIND-SET(v): | |
A = A βͺ {(u, v)} | |
UNION(u, v) | |
return A |
This file contains hidden or 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
import java.util.*; | |
class Solution { | |
public String solution(String number, int k) { | |
char[] arr = number.toCharArray(); | |
Stack<Integer> list = new Stack<>(); | |
for (int i = 0; i < arr.length; i++) { | |
int curr = (int) arr[i] - '0'; | |
while (!list.isEmpty() && k>0 && list.peek() < curr) { | |
list.pop(); |