Which one of the following has NOT been a name for Java?
Anonymous Quiz
3%
a) Oak
14%
b) Green
5%
c) Java
78%
d) Tree
what is the output of the ff.
float x = 2.2;
long y = 100;
System.out.println(x + y);
the new keyword is used to create new objects or instances of a class. It is essential for memory allocation in Java, as it initializes objects dynamically during runtime.
what is the output of the ff.
String ace = "Ace Coding";
System.out.println(ace.startsWith('A');
System.out.println(ace.endsWith('g');
for the above
Anonymous Quiz
67%
true, true
8%
true, false
14%
false, false
0%
false, true
11%
Error
💻 A2SV prep: Two pointers
🟢 Two sum
🟡 Two sum ll input array is sorted
👆The above two are easy; warm up
🟡 3sum Click here
Solution:
🟡 3sum closest :- click here
Solution:
🟡 4Sum :- click here
Solution:
🌟🚀 @AceCoding Presents! 🚀🌟
🟢 Two sum
🟡 Two sum ll input array is sorted
👆The above two are easy; warm up
🟡 3sum Click here
Solution:
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
res = []
nums.sort()
n = len(nums)
for i in range(n-2):
if nums[i] > 0:
break
if i > 0 and nums[i] == nums[i-1]:
continue
L, R = i + 1, n - 1
while L < R:
sum = nums[i] + nums[L] + nums[R]
if sum == 0:
res.append([nums[i], nums[L], nums[R]])
L +=1
R -=1
while L < R and nums[L] == nums[L-1]:
L += 1
while L < R and nums[R] == nums[R+1]:
R -= 1
elif sum > 0:
R -= 1
else:
L += 1
return res
🟡 3sum closest :- click here
Solution:
python
class Solution:
def threeSumClosest(self, nums: List[int], target: int) -> int:
nums.sort()
res = sum(nums[:3])
for i in range(len(nums)):
L, R = i+1, len(nums)-1
while L < R:
closest = nums[i] + nums[L] + nums[R]
if abs(target - closest) < abs(target - res):
res = closest
if closest > target:
R -= 1
elif closest < target:
L += 1
else:
return closest
return res
🟡 4Sum :- click here
Solution:
class Solution:
def fourSum(self, nums: List[int], target: int) -> List[List[int]]:
nums.sort()
n = len(nums)
res = []
for i in range(n-3):
if i > 0 and nums[i] == nums[i-1]:
continue
for j in range(i+1, n-2):
if j > i+1 and nums[j] == nums[j-1]:
continue
L, R = j + 1, n - 1
while L < R:
four_sum = nums[i] + nums[j] + nums[L] + nums[R]
if four_sum == target:
res.append([nums[i], nums[j], nums[L], nums[R]])
L += 1
R -= 1
while L < R and nums[L] == nums[L-1]:
L += 1
while L < R and nums[R] == nums[R+1]:
R -= 1
elif four_sum > target:
R -= 1
else:
L += 1
return res
🌟🚀 @AceCoding Presents! 🚀🌟
LeetCode
Two Sum - LeetCode
Can you solve this real interview question? Two Sum - You are given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you…
You may assume that each input would have exactly one solution, and you…
👍2
💡 Which side are you rocking, Theory or Practice. [Right or Left]
Anonymous Poll
18%
📚 Theory Master 📖
50%
🛠 Practice Pro 💻
32%
🔥 Both Boss 💪🦾