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
static void staircase(int n) { | |
for(int i = 0; i < n; ++i) { | |
String padd = ""; | |
while(padd.length() < (n-i-1)) padd += " "; | |
while(padd.length() < n) padd += "#"; | |
System.out.println(padd); | |
} | |
} |
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
def staircase(n): | |
# | |
# Write your code here. | |
# | |
for i in range(n): | |
padd = [] | |
while len(padd) < n-i-1: padd.append(" ") | |
while len(padd) < n: padd.append("#") | |
print("".join(padd)) |
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
def miniMaxSum(arr): | |
arr.sort() | |
print(sum(arr[:-1]), sum(arr[1:])) |
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
static void miniMaxSum(int[] arr) { | |
Arrays.sort(arr); | |
long minSum = 0; | |
long maxSum = 0; | |
for(int i = 0; i < arr.length - 1; ++i) minSum += arr[i]; | |
for(int i = 1; i < arr.length; ++i) maxSum += arr[i]; | |
System.out.println(minSum + " " + maxSum); | |
} |
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
def birthdayCakeCandles(ar): | |
return ar[0:].count(max(ar[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
static int birthdayCakeCandles(int[] ar) { | |
int max = ar[0]; | |
for(int i = 1; i < ar.length; ++i) { | |
if(ar[i] > max) max = ar[i]; | |
} | |
int occur = 0; | |
for(int e : ar) { | |
if(e == max) ++occur; | |
} | |
return occur; |
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
def timeConversion(s): | |
t, p = s[:2], s[-2:] | |
if(p == "AM"): | |
if(t == "12"): | |
t = "00" | |
else: | |
if(t != "12"): | |
t = str(int(t)+12) | |
return t + s[2:-2] |
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
static String timeConversion(String s) { | |
String t = s.substring(0, 2); | |
String p = s.substring(s.length() - 2, s.length()); | |
if(p.equals("AM")) { | |
if(t.equals("12")) t = "00"; | |
} else { | |
if(!t.equals("12")) t = Integer.toString(Integer.parseInt(t) + 12); | |
} | |
return t + s.substring(2, s.length()-2); |
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
[...document.querySelectorAll('tr td [data-original-title]')].forEach(el => {el.parentElement.parentElement.parentElement.style = "display: none;"}) |
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 static List<Integer> gradingStudents(List<Integer> grades) { | |
List<Integer> g = new ArrayList<>(); | |
for(Integer grade : grades) { | |
if(grade >= 38) { | |
int x = 5 + (Math.round(grade/5) * 5); | |
g.add(x - grade < 3 ? x : grade); | |
} else { | |
g.add(grade); | |
} | |
} |