question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
number-of-ways-to-arrive-at-destination
[C++] Dijkstra - Clean & Concise
c-dijkstra-clean-concise-by-anik_mahmud-yzsl
\ntypedef long long ll;\nconst ll mod=1e9+7;\nclass Solution {\npublic:\n int countPaths(int n, vector<vector<int>>& roads) {\n int m=roads.size();\n
anik_mahmud
NORMAL
2021-12-28T08:31:41.474897+00:00
2021-12-28T08:31:41.474927+00:00
336
false
```\ntypedef long long ll;\nconst ll mod=1e9+7;\nclass Solution {\npublic:\n int countPaths(int n, vector<vector<int>>& roads) {\n int m=roads.size();\n vector<vector<pair<int,int>>>v(n);\n for(auto x: roads){\n v[x[0]].push_back({x[1],x[2]});\n v[x[1]].push_back({x[0],x[2]...
3
0
[]
0
number-of-ways-to-arrive-at-destination
javascript dijkstra 132ms
javascript-dijkstra-132ms-by-henrychen22-6tw8
\nconst mod = 1e9 + 7;\nconst countPaths = (n, road) => {\n let adj = initializeGraph(n);\n for (const [u, v, cost] of road) {\n adj[u].push([v, co
henrychen222
NORMAL
2021-08-21T21:04:45.857459+00:00
2021-08-21T21:04:45.857490+00:00
653
false
```\nconst mod = 1e9 + 7;\nconst countPaths = (n, road) => {\n let adj = initializeGraph(n);\n for (const [u, v, cost] of road) {\n adj[u].push([v, cost]);\n adj[v].push([u, cost]);\n }\n return dijkstra(n, adj, 0);\n};\n\nconst dijkstra = (n, g, source) => { // g: adjacent graph list, n: tota...
3
1
['JavaScript']
3
number-of-ways-to-arrive-at-destination
Java faster than 100% (10ms) through Dijkstra with array for queue
java-faster-than-100-10ms-through-dijkst-k6bg
Since Java\'s PriorityQueue doesn\'t handle "decreaseKey" operation, if you use it you will have several times the same node in the queue. The algo still works
ricola
NORMAL
2021-08-21T18:06:10.660614+00:00
2021-08-22T13:23:30.384260+00:00
682
false
Since Java\'s PriorityQueue doesn\'t handle "decreaseKey" operation, if you use it you will have several times the same node in the queue. The algo still works but it\'s slower because of the duplicated elements in the queue. You can still implement your own queue manually though.\n\nYou can also use an array to repres...
3
0
[]
1
number-of-ways-to-arrive-at-destination
C++ Dijkstra
c-dijkstra-by-llc5pg-pel4
\nclass Solution {\n const int MOD = 1e9+7;\npublic:\n int countPaths(int n, vector<vector<int>>& roads) {\n vector<vector<pair<int, int>>> mat(n);
llc5pg
NORMAL
2021-08-21T16:37:50.108841+00:00
2021-08-21T16:37:50.108872+00:00
288
false
```\nclass Solution {\n const int MOD = 1e9+7;\npublic:\n int countPaths(int n, vector<vector<int>>& roads) {\n vector<vector<pair<int, int>>> mat(n);\n for (vector<int> road : roads) {\n mat[road[0]].push_back(make_pair(road[1], road[2]));\n mat[road[1]].push_back(make_pair(ro...
3
1
[]
2
number-of-ways-to-arrive-at-destination
Dijkstra algorithm || C++
dijkstra-algorithm-c-by-we_out_here-zubr
We may use here Dijkstra algorithm with small modification. \nLet\'s use additional array numWays, where numWays[i] - number of shortest paths from 0 to i verte
we_out_here
NORMAL
2021-08-21T16:05:06.413334+00:00
2021-08-21T16:19:34.884776+00:00
801
false
We may use here Dijkstra algorithm with small modification. \nLet\'s use additional array numWays, where numWays[i] - number of shortest paths from 0 to i vertex. \nWhen we update distance from current vertex to neighbors, we should check two situations:\n\t1. distance to u + w(u, v) < distance to v. Update distance, a...
3
0
[]
2
number-of-ways-to-arrive-at-destination
Java Priority Queue
java-priority-queue-by-mayank12559-wsdh
\npublic int countPaths(int n, int[][] roads) {\n long [][]dp = new long[n][2];\n ArrayList<long []> []graph = new ArrayList[n];\n for(int
mayank12559
NORMAL
2021-08-21T16:01:16.746575+00:00
2021-08-21T16:01:16.746623+00:00
962
false
```\npublic int countPaths(int n, int[][] roads) {\n long [][]dp = new long[n][2];\n ArrayList<long []> []graph = new ArrayList[n];\n for(int i=0;i<n;i++){\n graph[i] = new ArrayList();\n }\n for(int []road: roads){\n int src = road[0];\n int dest = ro...
3
0
[]
0
number-of-ways-to-arrive-at-destination
Number of Ways to Arrive at Destination
number-of-ways-to-arrive-at-destination-4uy3z
Code
Ansh1707
NORMAL
2025-03-23T20:13:19.028401+00:00
2025-03-23T20:13:19.028401+00:00
21
false
# Code ```python [] class Solution(object): def countPaths(self, n, roads): """ :type n: int :type roads: List[List[int]] :rtype: int """ MOD, graph = 10**9 + 7, {i: [] for i in range(n)} for u, v, t in roads: graph[u].append((v, t)) ...
2
0
['Python']
0
number-of-ways-to-arrive-at-destination
Floyd-warshall way
floyd-warshall-way-by-mm9139-4y4u
Complexity Time complexity: O(n^3) Space complexity: O(n^2) Code
mm9139
NORMAL
2025-03-23T13:32:34.747319+00:00
2025-03-23T13:32:34.747319+00:00
42
false
# Complexity - Time complexity: O(n^3) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(n^2) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```golang [] func countPaths(n int, roads [][]int) int { mod:=int(1e9)+7 dp:=make([][][2]int,n) for i:=range n{ dp[i...
2
0
['Go']
0
number-of-ways-to-arrive-at-destination
C#
c-by-adchoudhary-nyed
Code
adchoudhary
NORMAL
2025-03-23T09:57:36.422645+00:00
2025-03-23T09:57:36.422645+00:00
59
false
# Code ```csharp [] public class Solution { public int CountPaths(int n, int[][] roads) { int mod = 1_000_000_007; var adj = new List<(int, int)>[n]; for (int i = 0; i < n; i++) adj[i] = new List<(int, int)>(); foreach (var road in roads) { adj[road[0]].Add((road[1], road[2])); adj[roa...
2
0
['C#']
0
number-of-ways-to-arrive-at-destination
Dijkstra’s Made Easy | Interview-Ready Solution with Intuitive Explanation
simple-and-intuitive-explanation-using-d-qkht
IntuitionTo solve this problem, we need to find the shortest path, which naturally suggests using Dijkstra’s algorithm. Additionally, we need to count the numbe
abukafq
NORMAL
2025-03-23T06:19:59.669265+00:00
2025-03-23T12:00:48.327564+00:00
202
false
# Intuition To solve this problem, we need to find the shortest path, which naturally suggests using Dijkstra’s algorithm. Additionally, we need to count the number of ways to reach the destination using the shortest path. Every time we encounter a minimum distance, we accumulate the number of ways we reached that node...
2
0
['Dynamic Programming', 'Graph', 'Shortest Path', 'Java']
0
number-of-ways-to-arrive-at-destination
JAVA SOLUTION USING DIJISKTRA'S ALGO
java-solution-using-dijisktras-algo-by-d-o97i
IntuitionApproachComplexity Time complexity: Space complexity: Code
divyansh_2069
NORMAL
2025-03-23T05:21:24.006041+00:00
2025-03-23T05:21:24.006041+00:00
398
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
2
0
['Java']
0
number-of-ways-to-arrive-at-destination
Easy C++ Code || Simple to Understand
easy-c-code-simple-to-understand-by-anki-383y
Code
ankit_mohapatra
NORMAL
2025-03-23T05:08:37.478879+00:00
2025-03-23T05:08:37.478879+00:00
256
false
# Code ```cpp [] class Solution { public: int countPaths(int n, vector<vector<int>>& roads) { vector<vector<pair<int, int>>> graph(n); for (const auto& road : roads) { int u = road[0], v = road[1], time = road[2]; graph[u].emplace_back(v, time); graph[v].emplace_...
2
0
['Dynamic Programming', 'Graph', 'Topological Sort', 'Shortest Path', 'C++']
1
number-of-ways-to-arrive-at-destination
EAsy code | Must try
easy-code-must-try-by-notaditya09-ebvs
IntuitionApproachComplexity Time complexity: Space complexity: Code
NotAditya09
NORMAL
2025-03-23T05:06:22.358399+00:00
2025-03-23T05:06:22.358399+00:00
256
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
2
0
['Java']
0
number-of-ways-to-arrive-at-destination
Kotlin || Dijkstra || DFS
kotlin-dijkstra-dfs-by-nazmulcuet11-6qeq
IntuitionApproachComplexity Time complexity: Space complexity: Code
nazmulcuet11
NORMAL
2025-03-23T04:07:08.648363+00:00
2025-03-23T04:07:08.648363+00:00
71
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
2
0
['Dynamic Programming', 'Depth-First Search', 'Breadth-First Search', 'Graph', 'Kotlin']
0
number-of-ways-to-arrive-at-destination
Simple Dijkstra || Easy Explanation
simple-dijkstra-easy-explanation-by-rajn-c1d5
IntuitionYou're given a weighted undirected graph with n nodes and some roads between them. You want to: Find the number of different shortest paths from node 0
rajnandi006
NORMAL
2025-03-23T03:36:35.958706+00:00
2025-03-23T03:36:35.958706+00:00
21
false
# Intuition You're given a weighted undirected graph with n nodes and some roads between them. You want to: - Find the number of different shortest paths from node 0 to node n - 1. It's not just about the shortest path length, but how many ways you can achieve that shortest time. # Approach Imagine you're running Dij...
2
0
['Graph', 'Shortest Path', 'C++']
0
number-of-ways-to-arrive-at-destination
Python Solution dijkstra's with few changes
python-solution-dijkstras-with-few-chang-sey7
IntuitionApproachComplexity Time complexity: Space complexity: Code
ANiSh684
NORMAL
2025-03-23T02:13:13.795726+00:00
2025-03-23T02:13:13.795726+00:00
398
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
2
1
['Graph', 'Shortest Path', 'Python3']
0
number-of-ways-to-arrive-at-destination
Striver's JAVA code that passes all TESTCASES
strivers-java-code-that-passes-all-testc-pjq9
Code
glyderVS
NORMAL
2025-03-15T17:01:35.983411+00:00
2025-03-15T17:01:35.983411+00:00
272
false
# Code ```java [] class Pair{ long first; int second; Pair(long _first,int _second){ this.first=_first; this.second=_second; } } class Solution { public int countPaths(int n, int[][] roads) { ArrayList<ArrayList<Pair>>adj=new ArrayList<>(); for(int i=0;i<n;i++){ ...
2
0
['Java']
0
number-of-ways-to-arrive-at-destination
Dynamic programming + dijkstra
dynamic-programming-dijkstra-by-samman_v-4yez
Code
samman_varshney
NORMAL
2025-02-10T17:17:55.065494+00:00
2025-02-10T17:17:55.065494+00:00
199
false
# Code ```java [] import java.util.*; class Solution { public int countPaths(int n, int[][] roads) { ArrayList<ArrayList<int[]>> adj = new ArrayList<>(); for (int i = 0; i < n; i++) adj.add(new ArrayList<>()); for (int[] x : roads) { adj.get(x[0]).add(new int[]{x[...
2
0
['Dynamic Programming', 'Graph', 'Shortest Path', 'Java']
0
number-of-ways-to-arrive-at-destination
Striver's Corrected Code : Java 100% Working
strivers-corrected-code-java-100-working-ibv7
\n# Complexity\n- Time complexity:\nO(n*log(n))\n\n- Space complexity:\nO(n)\n\n# Code\n\n class Pair{\n long first;\n long second;\n public Pair(long
doravivek
NORMAL
2024-08-11T20:07:15.904031+00:00
2024-08-11T20:07:15.904085+00:00
828
false
\n# Complexity\n- Time complexity:\n$$O(n*log(n))$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\n class Pair{\n long first;\n long second;\n public Pair(long dis,long node){\n this.first=dis;\n this.second=node;\n }\n}\nclass Solution {\n public int countPaths(int n, int[][] roads) {\n ...
2
1
['Dynamic Programming', 'Graph', 'Topological Sort', 'Shortest Path', 'C++', 'Java', 'Python3']
1
number-of-ways-to-arrive-at-destination
Dijkstra’s Algorithm || Striver code correction || Java
dijkstras-algorithm-striver-code-correct-xnxq
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
rajshah0192000
NORMAL
2024-07-23T17:20:09.427745+00:00
2024-07-23T17:20:09.427779+00:00
661
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(N*Log(N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)+O(n)=O(n)\n<!-- Add your space complexi...
2
0
['Java']
1
number-of-ways-to-arrive-at-destination
C++ solution|| Dijkastra ALGO
c-solution-dijkastra-algo-by-deepakiit12-42ed
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
deepakiit1210
NORMAL
2024-07-10T12:41:33.303902+00:00
2024-07-10T12:41:33.303943+00:00
1,186
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
number-of-ways-to-arrive-at-destination
Simple modification in dijkstra's algorithm
simple-modification-in-dijkstras-algorit-13xs
Slight Modification in dijkstra\'s algorithm\n# Approach\n### 1. Initialization:\n- Mark the distance to the source node as 0 and to all other nodes as LONG_MAX
18bce192
NORMAL
2024-05-06T05:04:08.600018+00:00
2024-05-06T05:06:08.861678+00:00
863
false
Slight Modification in dijkstra\'s algorithm\n# Approach\n### **1. Initialization:**\n- Mark the distance to the source node as 0 and to all other nodes as LONG_MAX.\n- Use a priority queue (min-heap) to efficiently fetch the next node with the smallest tentative distance.\n\n---\n\n\n### **2. Main Loop:**\n- Extract t...
2
0
['Dynamic Programming', 'C++']
0
number-of-ways-to-arrive-at-destination
EASY Striver's Approach | C++ |
easy-strivers-approach-c-by-harshitgupta-79d1
Intuition\n Describe your first thoughts on how to solve this problem. \nWe are given a graph representing cities connected by roads with varying travel times.
harshitgupta_2643
NORMAL
2024-03-22T09:40:40.689479+00:00
2024-03-22T09:40:40.689506+00:00
564
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe are given a graph representing cities connected by roads with varying travel times. We need to find the number of shortest paths from the source city (0) to the destination city (n-1) with the minimum time.\n\n# Approach\n<!-- Describe...
2
0
['C++']
1
number-of-ways-to-arrive-at-destination
✅✅C++ - Beats 100% || Dijkstra algorithm || Easy Understanding ✅✅
c-beats-100-dijkstra-algorithm-easy-unde-ocmy
Intuition\nThe code likely implements Dijkstra\'s algorithm with modifications to track the number of shortest paths.\n# Approach\n1. Graph Representation: The
arslanarsal
NORMAL
2024-01-03T17:16:43.265479+00:00
2024-01-03T17:16:43.265525+00:00
699
false
# Intuition\nThe code likely implements Dijkstra\'s algorithm with modifications to track the number of shortest paths.\n# Approach\n1. Graph Representation: The roads vector represents edges between nodes with their weights.\n2. Initialization: Initializes necessary data structures like adj (adjacency list), weight (d...
2
0
['Dynamic Programming', 'Graph', 'Topological Sort', 'Shortest Path', 'C++']
1
number-of-ways-to-arrive-at-destination
All Test Cases|| New Updated solution|| Java
all-test-cases-new-updated-solution-java-29ac
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
puneet-yadav
NORMAL
2023-08-15T08:44:48.919572+00:00
2023-08-15T08:44:48.919603+00:00
1,314
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['Breadth-First Search', 'Graph', 'C++', 'Java']
2
number-of-ways-to-arrive-at-destination
Straightforward Python Dijkstra's
straightforward-python-dijkstras-by-hell-ebjp
\n\n# Code\n\nfrom heapq import heapify, heappush, heappop\nclass Solution:\n def countPaths(self, n: int, roads: List[List[int]]) -> int:\n\n adj = c
hellzone1903
NORMAL
2023-06-27T05:41:44.382696+00:00
2023-06-27T05:41:44.382729+00:00
186
false
\n\n# Code\n```\nfrom heapq import heapify, heappush, heappop\nclass Solution:\n def countPaths(self, n: int, roads: List[List[int]]) -> int:\n\n adj = collections.defaultdict(list)\n\n for r in roads:\n adj[r[0]].append((r[1], r[2]))\n adj[r[1]].append((r[0], r[2]))\n \n ...
2
0
['Python3']
1
number-of-ways-to-arrive-at-destination
Bellman Ford + map c++ (slow but it is what it is)
bellman-ford-map-c-slow-but-it-is-what-i-kosh
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
pathetik_coder
NORMAL
2023-04-17T21:51:32.856208+00:00
2023-04-17T21:51:32.856246+00:00
84
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
number-of-ways-to-arrive-at-destination
C++ | Using Priority Queue and Set | 2 Approaches highly commented
c-using-priority-queue-and-set-2-approac-ebfz
Using Priority Queue\ncpp\nclass Solution {\npublic:\n /*\n Approach: We will use the dijsktra algorithm to find out the shortest distance then calcul
SubratYeeshu
NORMAL
2023-01-09T16:29:35.663309+00:00
2023-01-09T16:31:23.604590+00:00
1,073
false
**Using Priority Queue**\n```cpp\nclass Solution {\npublic:\n /*\n Approach: We will use the dijsktra algorithm to find out the shortest distance then calculate number of ways you can arrive at your destination in the shortest time. Take distance as long long\n 1. Using a Priority Queue\n 2. Usi...
2
0
['Graph', 'C', 'Heap (Priority Queue)', 'Ordered Set', 'C++']
0
number-of-ways-to-arrive-at-destination
Java-Using Edge Class
java-using-edge-class-by-piyush_chhawach-csd5
Please UpVote if you liked my solution. \uD83D\uDE42\nIf you didn\'t understand,Mail me @piyushchhawachharia@gmail.com and I\'ll explain that to you one-on-one.
piyush_chhawachharia
NORMAL
2023-01-03T13:40:04.006312+00:00
2023-01-03T13:40:04.006350+00:00
1,713
false
Please UpVote if you liked my solution. \uD83D\uDE42\nIf you didn\'t understand,Mail me @piyushchhawachharia@gmail.com and I\'ll explain that to you one-on-one.\nThe Coding Community Always Sticks Together! :)\n\n# Code\n```\nclass Solution {\n static class Edge{\n int vtc;\n int nbr;\n int wt;\...
2
0
['Java']
0
number-of-ways-to-arrive-at-destination
Commented and explained solution
commented-and-explained-solution-by-gare-uokm
``` \npublic int countPaths(int n, int[][] roads) {\n //the approach here will be same as djskarta but we will require to count the number of \n //ways w
20250206.garethbale11
NORMAL
2022-11-07T02:21:51.443818+00:00
2022-11-07T02:23:40.975147+00:00
844
false
``` \npublic int countPaths(int n, int[][] roads) {\n //the approach here will be same as djskarta but we will require to count the number of \n //ways we reached to every node through short cost path\n //Catch is, whenver you find a better way to reach a particular vertex update the number of ways \n ...
2
0
['Dynamic Programming', 'Java']
1
24-game
[JAVA] Easy to understand. Backtracking.
java-easy-to-understand-backtracking-by-1teq3
\nclass Solution {\n\n boolean res = false;\n final double eps = 0.001;\n\n public boolean judgePoint24(int[] nums) {\n List<Double> arr = new A
zhang00000
NORMAL
2017-09-17T07:26:13.573000+00:00
2018-10-26T22:24:28.165053+00:00
43,933
false
```\nclass Solution {\n\n boolean res = false;\n final double eps = 0.001;\n\n public boolean judgePoint24(int[] nums) {\n List<Double> arr = new ArrayList<>();\n for(int n: nums) arr.add((double) n);\n helper(arr);\n return res;\n }\n\n private void helper(List<Double> arr){\...
203
4
[]
36
24-game
Short Python
short-python-by-stefanpochmann-3f9s
def judgePoint24(self, nums):\n if len(nums) == 1:\n return math.isclose(nums[0], 24)\n return any(self.judgePoint24([x] + rest)\n
stefanpochmann
NORMAL
2017-09-17T18:35:45.136000+00:00
2018-10-17T10:05:24.675089+00:00
21,991
false
def judgePoint24(self, nums):\n if len(nums) == 1:\n return math.isclose(nums[0], 24)\n return any(self.judgePoint24([x] + rest)\n for a, b, *rest in itertools.permutations(nums)\n for x in {a+b, a-b, a*b, b and a/b})\n\nJust go through all pairs of numbe...
185
7
[]
21
24-game
C++, Concise code
c-concise-code-by-zestypanda-5s39
\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n do {\n if (valid(nums)) ret
zestypanda
NORMAL
2017-09-17T16:12:01.969000+00:00
2018-10-26T11:54:49.162649+00:00
15,218
false
```\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n do {\n if (valid(nums)) return true;\n } while(next_permutation(nums.begin(), nums.end()));\n return false;\n }\nprivate:\n bool valid(vector<int>& nums) {\n ...
167
3
[]
21
24-game
Thinking Process - Backtracking
thinking-process-backtracking-by-graceme-0efu
Thanks to (, ) operators, we don\'t take order of operations into consideration.\n>\n>Let\'s say, we pick any two numbers, a and b, and apply any operator +, -,
gracemeng
NORMAL
2018-10-09T06:44:31.388353+00:00
2019-12-22T15:42:27.586598+00:00
9,459
false
>Thanks to `(, )` operators, we don\'t take order of operations into consideration.\n>\n>Let\'s say, we pick any two numbers, `a` and `b`, and apply any operator `+, -, *, / `, assuming that the expression is surrounded with parenthesis, e.g. `(a + b)`. Then, the result of `(a + b)` instead of `a` and `b` would partici...
123
2
[]
10
24-game
Very Easy JAVA DFS
very-easy-java-dfs-by-chnsht-jexm
```\npublic boolean judgePoint24(int[] nums) {\n List list = new ArrayList<>();\n for (int i : nums) {\n list.add((double) i);\n
chnsht
NORMAL
2018-02-07T01:47:43.147000+00:00
2018-09-21T04:17:54.778466+00:00
10,392
false
```\npublic boolean judgePoint24(int[] nums) {\n List<Double> list = new ArrayList<>();\n for (int i : nums) {\n list.add((double) i);\n }\n return dfs(list);\n }\n\n private boolean dfs(List<Double> list) {\n if (list.size() == 1) {\n if (Math.abs(list.get...
112
2
[]
12
24-game
Short intuitive python solution
short-intuitive-python-solution-by-q1331-7hvw
\nclass Solution:\n def judgePoint24(self, nums):\n """\n :type nums: List[int]\n :rtype: bool\n """\n if len(nums) == 1 a
q1331
NORMAL
2018-08-30T09:20:01.326685+00:00
2018-10-02T10:12:48.980007+00:00
4,456
false
```\nclass Solution:\n def judgePoint24(self, nums):\n """\n :type nums: List[int]\n :rtype: bool\n """\n if len(nums) == 1 and abs(nums[0] - 24) <= 0.001: return True\n for i in range(len(nums)):\n for j in range(len(nums)):\n if i != j:\n ...
65
1
[]
12
24-game
[679. 24 Game] C++ Recursive
679-24-game-c-recursive-by-jasonshieh-v9t5
Search for all possible cases.\nLooks like backtracking...\n\n class Solution {\n public:\n double elipson = pow(10.0, -5);\n vector operations = {'
jasonshieh
NORMAL
2017-09-17T22:26:03.910000+00:00
2018-10-02T03:07:02.027682+00:00
6,547
false
Search for all possible cases.\nLooks like backtracking...\n\n class Solution {\n public:\n double elipson = pow(10.0, -5);\n vector<char> operations = {'+','-','*','/'};\n bool judgePoint24(vector<int>& nums) {\n vector<double> vec;\n for(auto n : nums){\n vec.push_back(n*1.0);\...
44
0
[]
11
24-game
Python > 90% ignore brackets solution (O(1) ~= 13824)
python-90-ignore-brackets-solution-o1-13-yglh
\nimport itertools\nclass Solution(object):\n def judgePoint24(self, nums):\n """\n :type nums: List[int]\n :rtype: bool\n """\n
neai_wu
NORMAL
2017-12-17T06:00:40.050000+00:00
2018-09-30T16:07:54.131487+00:00
4,919
false
```\nimport itertools\nclass Solution(object):\n def judgePoint24(self, nums):\n """\n :type nums: List[int]\n :rtype: bool\n """\n Ops = list(itertools.product([add,sub,mul,div], repeat=3))\n for ns in set(itertools.permutations(nums)):\n for ops in Ops:\n ...
29
1
[]
3
24-game
Python - 80ms
python-80ms-by-azsefi-nbas
\nimport itertools as it\n\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n if len(nums) == 1:\n return round(nums[0],
azsefi
NORMAL
2019-05-26T22:31:55.223762+00:00
2019-05-26T22:31:55.223792+00:00
4,575
false
```\nimport itertools as it\n\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n if len(nums) == 1:\n return round(nums[0], 4) == 24\n else:\n for (i, m), (j, n) in it.combinations(enumerate(nums), 2):\n new_nums = [x for t, x in enumerate(num...
22
2
['Python3']
2
24-game
java recursive solution
java-recursive-solution-by-2499370956-g6nc
Repeatedly select 2 numbers (all combinations) and compute, until there is only one number, check if it's 24.\n\nclass Solution {\n public boolean judgePoint
2499370956
NORMAL
2017-09-17T13:54:39.082000+00:00
2017-09-17T13:54:39.082000+00:00
6,753
false
Repeatedly select 2 numbers (all combinations) and compute, until there is only one number, check if it's 24.\n```\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n return f(new double[] {nums[0], nums[1], nums[2], nums[3]});\n }\n \n private boolean f(double[] a) {\n if (a.lengt...
22
1
[]
10
24-game
Backtracking beats 95.29% [Java]
backtracking-beats-9529-java-by-zzitai-oehy
Apparently, there are limited number of combinations for cards and operators (+-*/()). One idea is to search among all the possible combinations. This is what b
zzitai
NORMAL
2017-12-30T20:48:28.530000+00:00
2017-12-30T20:48:28.530000+00:00
1,699
false
Apparently, there are limited number of combinations for cards and operators (``+-*/()``). One idea is to search among all the possible combinations. This is what backtracking does.\n\nNote that ``()`` play no role in this question. Say, parentheses give some operators a higher priority to be computed. However, the fol...
20
0
[]
3
24-game
C++, Concise code with only one helper function
c-concise-code-with-only-one-helper-func-qrjn
\nclass Solution {\n vector<double> combine2(double a, double b) {\n return {a / b, b / a, a + b, a - b, b - a, a * b};\n }\n static constexpr d
snliaregs
NORMAL
2019-10-09T14:08:01.553821+00:00
2019-10-09T14:08:01.553868+00:00
1,520
false
```\nclass Solution {\n vector<double> combine2(double a, double b) {\n return {a / b, b / a, a + b, a - b, b - a, a * b};\n }\n static constexpr double eps = 1e-4;\npublic:\n bool judgePoint24(vector<int>& nums) {\n vector<int> id ({0, 1, 2, 3});\n do {\n int a = nums[id[0]]...
16
0
[]
2
24-game
Python with explanation - Generate All Possibilities
python-with-explanation-generate-all-pos-ueaj
Use itertools.permutations to generate all the possible operands and operators to form an array of length 7, representing an equation of 4 operands and 3 operat
yangshun
NORMAL
2017-09-17T05:36:36.901000+00:00
2018-10-11T05:35:38.052418+00:00
4,827
false
1. Use `itertools.permutations` to generate all the possible operands and operators to form an array of length 7, representing an equation of 4 operands and 3 operators.\n2. The `possible` function tries to evaluate the equation with different combinations of brackets, terminating as soon as an equation evaluates to 24...
15
2
[]
1
24-game
C++ DFS Solution easy-understanding
c-dfs-solution-easy-understanding-by-roh-xdm7
\nclass Solution {\n vector<double> compute(double x, double y)\n {\n return {x + y, x - y, y - x, x * y, x / y, y / x};\n }\n \n bool hel
rohit_raj_1234
NORMAL
2021-07-04T10:35:54.343735+00:00
2021-07-04T10:35:54.343773+00:00
1,755
false
```\nclass Solution {\n vector<double> compute(double x, double y)\n {\n return {x + y, x - y, y - x, x * y, x / y, y / x};\n }\n \n bool helper(vector<double> &v){\n if(v.size()==1) return abs(v[0] - 24) < 0.0001;\n \n for(int i=0; i < v.size(); i++){\n for(int j=i...
13
0
['Depth-First Search', 'C']
4
24-game
[Java] Clean backtracking code with explanation. Beats 100%
java-clean-backtracking-code-with-explan-1w2t
Apply backtracking: Iterate over all ways of choosing 2 numbers and apply all operators on them in both orders (i.e. a operator b and b operator a). Repeat the
shk10
NORMAL
2020-12-10T21:38:22.384740+00:00
2020-12-10T21:40:52.108815+00:00
2,161
false
**Apply backtracking:** Iterate over all ways of choosing 2 numbers and apply all operators on them in both orders (i.e. ```a operator b``` and ```b operator a```). Repeat the process recursively on remaining numbers and the result from computation of these 2 numbers. Base case for this recursion is when only one numbe...
12
0
['Backtracking', 'Java']
3
24-game
1 line Java solution, faster than 100%, less memory than 100%, easy to understand
1-line-java-solution-faster-than-100-les-lcqf
\nclass Solution\n{\n\tpublic boolean judgePoint24(int[] nums) {\n\t\treturn Arrays.equals(nums, new int[] { 4, 1, 8, 7 }) || Arrays.equals(nums, new int[] { 1,
david1121
NORMAL
2019-07-27T12:52:24.677021+00:00
2019-07-29T04:34:06.430007+00:00
1,009
false
```\nclass Solution\n{\n\tpublic boolean judgePoint24(int[] nums) {\n\t\treturn Arrays.equals(nums, new int[] { 4, 1, 8, 7 }) || Arrays.equals(nums, new int[] { 1, 3, 4, 6 }) || Arrays.equals(nums, new int[] { 1, 3, 2, 6 }) || Arrays.equals(nums, new int[] { 1, 4, 6, 1 }) || Arrays.equals(nums, new int[] { 1, 7, 4, 5 }...
12
6
[]
7
24-game
Simple Python
simple-python-by-hongsenyu-xj4d
\n\'\'\'\nBecause of (), we can give +, - the same priority as *, /\nPick any two numbers from nums, calculate results for all possible operations with these tw
hongsenyu
NORMAL
2020-02-09T02:21:21.034281+00:00
2020-02-09T02:21:21.034312+00:00
1,113
false
```\n\'\'\'\nBecause of (), we can give +, - the same priority as *, /\nPick any two numbers from nums, calculate results for all possible operations with these two nums.\nTry each result by adding the result to remaining numbers and solve the problem recursively.\nReturn True, if the last number is 24.\nTime: O(1), 2A...
10
0
['Backtracking']
3
24-game
a few solutions
a-few-solutions-by-claytonjwong-q0c9
Try every permutation of the input array A with every precedent of operators +, -, *, / for adjacent array values, initially a,b,c,d recursively reduced to a,b,
claytonjwong
NORMAL
2018-05-22T02:10:42.469309+00:00
2022-06-29T18:04:51.089759+00:00
1,311
false
Try every permutation of the input array `A` with every precedent of operators `+`, `-`, `*`, `/` for adjacent array values, initially `a`,`b`,`c`,`d` recursively reduced to `a`,`b`,`c` recursively reduced to `a`,`b` with recusive base case `a` which we compare to a epilson value, ie. a small value to deterine floating...
10
0
[]
2
24-game
Python useful solution
python-useful-solution-by-lee215-7isd
This is not a very efficace solution. Because it use evalfunction.\nIn fact I wrote a function to help me find all solutions for 24 game.\nEfficacy was not that
lee215
NORMAL
2017-09-17T20:57:10.313000+00:00
2017-09-17T20:57:10.313000+00:00
1,705
false
This is not a very efficace solution. Because it use ```eval```function.\nIn fact I wrote a function to help me find all solutions for 24 game.\nEfficacy was not that important. Then I met this problem I just modified my original solution to return just ```True``` or ```False```\n\n\n````\n def judgePoint24(self, nu...
10
2
[]
2
24-game
[Python] Elegant Solution
python-elegant-solution-by-lu-ma-x5fh
No itertools required.\n\ncards is used as both queue and stack to achieve permutations and back tracking\n\n\npython\nclass Solution:\n def judgePoint24(sel
lu-ma
NORMAL
2022-03-05T14:49:57.813951+00:00
2022-03-08T07:19:25.603827+00:00
1,244
false
No `itertools` required.\n\n`cards` is used as both **queue** and **stack** to achieve **permutations** and **back tracking**\n\n\n``` python\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n if len(cards) == 1:\n return math.isclose(cards[0], 24)\n \n for _ in ra...
8
0
['Backtracking', 'Python']
1
24-game
Java DFS Solution with Explanation
java-dfs-solution-with-explanation-by-co-iywi
Here we are trying every combination , first we are tryong every combination with 2 number .\nFor each combination , we are creating the whole input again and r
coderInUS
NORMAL
2021-05-19T05:06:45.262033+00:00
2021-05-19T05:35:45.884249+00:00
1,429
false
Here we are trying every combination , first we are tryong every combination with 2 number .\nFor each combination , we are creating the whole input again and running the dfs and repeat the same process .\n```\nclass Solution {\n public boolean judgePoint24(int[] cards) {\n List<Double> in=new ArrayList<>();\...
7
2
['Depth-First Search', 'Java']
4
24-game
Easy readable javascript solution
easy-readable-javascript-solution-by-raj-869b
\nconst judgePoint24 = function(nums) {\n\t//converting all the integers to decimal numbers.\n nums = nums.map(num => Number(num.toFixed(4)));\n \n\t//Fun
rajinisha001
NORMAL
2020-07-12T21:04:48.887982+00:00
2020-07-12T21:04:48.888034+00:00
787
false
```\nconst judgePoint24 = function(nums) {\n\t//converting all the integers to decimal numbers.\n nums = nums.map(num => Number(num.toFixed(4)));\n \n\t//Function that calculates all possible values after all operations on the numbers passed\n const computeTwoNums = (num1, num2) => {\n return [num1 + nu...
7
0
['Depth-First Search', 'JavaScript']
0
24-game
Python 3 || 9 lines, dfs || T/S: 37% / 99%
python-3-9-lines-dfs-ts-37-99-by-spauldi-cmy6
\ndiv = lambda x,y: reduce(truediv,(x,y)) if y else inf\nops = (add, sub, mul, div)\n\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n\
Spaulding_
NORMAL
2023-07-11T20:06:28.178083+00:00
2024-05-29T17:27:53.588818+00:00
1,080
false
```\ndiv = lambda x,y: reduce(truediv,(x,y)) if y else inf\nops = (add, sub, mul, div)\n\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n\n def dfs(c: list) -> bool:\n\n if len(c) <2 : return isclose(c[0], 24)\n \n for p in set(permutations(c)):\n ...
6
0
['Python3']
0
24-game
679: Solution with step by step explanation
679-solution-with-step-by-step-explanati-8usi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Define a helper function called "generate" that takes in two float val
Marlen09
NORMAL
2023-03-20T06:55:22.037368+00:00
2023-03-20T06:55:22.037407+00:00
1,563
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Define a helper function called "generate" that takes in two float values "a" and "b" and returns a list of float values that represent all possible arithmetic combinations of "a" and "b".\n2. Define another helper functi...
6
0
['Array', 'Math', 'Backtracking', 'Python', 'Python3']
0
24-game
Python, dfs, backtracking
python-dfs-backtracking-by-jered0910-12j7
\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n if not nums:\n return False\n return self.dfs(nums, 4)\n
Jered0910
NORMAL
2021-02-13T00:34:31.922117+00:00
2022-06-13T14:25:59.756427+00:00
1,105
false
```\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n if not nums:\n return False\n return self.dfs(nums, 4)\n \n \n def dfs(self, nums, n):\n if n == 1:\n if abs(nums[0] - 24) <= 1E-6 :\n return True\n \n for i ...
6
0
['Backtracking', 'Depth-First Search', 'Python']
3
24-game
Python3 straightforward recursive solution Faster than 91%
python3-straightforward-recursive-soluti-4qps
\tclass Solution: \n\t\tdef judgePoint24(self, nums: List[int]) -> bool:\n\t\t\t# recursively \'glue\' 2 numbers as a new number, and try to make 24 with the
baiqiang_leetcode
NORMAL
2020-05-13T11:10:59.484521+00:00
2020-05-13T11:10:59.484556+00:00
354
false
\tclass Solution: \n\t\tdef judgePoint24(self, nums: List[int]) -> bool:\n\t\t\t# recursively \'glue\' 2 numbers as a new number, and try to make 24 with the new nums list\n\t\t\t# at the end, when len(nums) = 1, check if it is 24 (due to division some precision loss should be expected, here set as 1e-8 )\n\n\t\t\t# ...
6
0
[]
1
24-game
Simple python dfs + memorization
simple-python-dfs-memorization-by-roc571-jbfz
added precision check fix\n\n\nclass Solution(object):\n def judgePoint24(self, nums):\n """\n :type nums: List[int]\n :rtype: bool\n
roc571
NORMAL
2017-09-17T16:29:26.725000+00:00
2017-09-17T16:29:26.725000+00:00
1,345
false
added precision check fix\n\n```\nclass Solution(object):\n def judgePoint24(self, nums):\n """\n :type nums: List[int]\n :rtype: bool\n """\n hs = {}\n return self.helper(nums, hs)\n \n def helper(self, nums, hs):\n #print "debug", nums\n if len(nums) ==...
6
0
[]
1
24-game
Numerical Error when doing division for Case [3, 3, 8, 8]
numerical-error-when-doing-division-for-30wj0
I am just trying to figure out a naive solution before I optimize the algorithm. \n\nIt seems that I ran into numerical issue in Case [3,3,8,8]. I tried to debu
linger_baruch
NORMAL
2017-10-16T20:27:34.100000+00:00
2018-08-30T14:58:46.383149+00:00
695
false
I am just trying to figure out a naive solution before I optimize the algorithm. \n\nIt seems that I ran into numerical issue in Case [3,3,8,8]. I tried to debug and it seems it calculates 8/3 as 2.6666666666666665, which in turn gives some number very close to 24.0 but not exact for 8 / (3 - 8 / 3). What should I do i...
6
0
[]
1
24-game
recursion, backtraking, all possible iterations easy explained
recursion-backtraking-all-possible-itera-fkwb
Intuition\nwe will select two pair of elemets and perform all given mathematical operations on that pair and then we store them in in a vector and puch the re
ranaujjawal692
NORMAL
2023-08-26T11:04:18.527975+00:00
2023-08-26T11:04:18.527996+00:00
760
false
# Intuition\nwe will select two pair of elemets and perform all given mathematical operations on that pair and then we store them in in a vector and puch the result of each operation step by step by pushing them into a newly created vector with consists the calculated result and all no\'s except pair whose result is ...
5
0
['C++']
1
24-game
C++ Solution. Very concise and simple code. (much conciser than most)
c-solution-very-concise-and-simple-code-22w8g
C++\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& nums) {\n vector<double> tmp(nums.begin(), nums.end());\n return dfs(tmp);\n
doub7e
NORMAL
2020-01-06T08:45:56.377639+00:00
2020-01-06T08:45:56.377690+00:00
533
false
```C++\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& nums) {\n vector<double> tmp(nums.begin(), nums.end());\n return dfs(tmp);\n }\nprivate:\n bool dfs(vector<double>& nums){\n if(nums.size() == 1) return fabs(nums[0] - 24) < 1e-8;\n for(int i = 0; i + 1 < nums.size()...
5
0
[]
0
24-game
C++ solution, Short, Easy to understand
c-solution-short-easy-to-understand-by-m-uv2d
\nclass Solution {\npublic:\n bool f(vector<double> &s){\n if(s.size() == 1) return abs(s[0]-24)<pow(10, -2);\n for(int i=0; i<s.size()-1; i++)
MrGamer2801
NORMAL
2023-07-08T20:22:14.531471+00:00
2023-07-08T20:22:14.531488+00:00
349
false
```\nclass Solution {\npublic:\n bool f(vector<double> &s){\n if(s.size() == 1) return abs(s[0]-24)<pow(10, -2);\n for(int i=0; i<s.size()-1; i++)\n {\n for(int j=0; j<4; j++)\n {\n double a;\n if(j==0) a = s[i]+s[i+1];\n else if...
4
0
['Depth-First Search', 'C++']
0
24-game
Easy to understand (with comments) Backtracking > 90% [C++]
easy-to-understand-with-comments-backtra-2l3l
\nclass Solution {\n bool found;\n vector<double> nums;\n char ops[4] = {\'+\', \'-\', \'*\', \'/\'};\n const double eps = 1e-9;\n \npublic:\n
MohammadOTaha
NORMAL
2022-04-12T23:10:58.328135+00:00
2022-04-12T23:14:16.866303+00:00
700
false
```\nclass Solution {\n bool found;\n vector<double> nums;\n char ops[4] = {\'+\', \'-\', \'*\', \'/\'};\n const double eps = 1e-9;\n \npublic:\n double calc(double x, double y, char op) {\n if (op == \'+\') return x + y;\n else if (op == \'-\') return x - y;\n else if (op == \'*\...
4
0
['Backtracking', 'C']
0
24-game
C++ - Easy beats 100% of solutions [0 ms]
c-easy-beats-100-of-solutions-0-ms-by-dh-5hed
There are only 5 possible ways of adding brackets to an expression of length 4.\n\nLets\' say the expression nums = { a , b, c , d}. The only possible sequence
dheer1206
NORMAL
2021-02-27T10:00:37.506160+00:00
2021-02-27T10:21:18.302620+00:00
563
false
There are only 5 possible ways of adding brackets to an expression of length 4.\n\nLets\' say the expression nums = { a , b, c , d}. The only possible sequence of brackets is:\nHere **op** represent any operation in the set { + , - , / , * }\n1. (a op1 b) op2 (c op3 d)\n2. ((a op1 b) op2 c) op3 d\n3. a op1 (b op2 c) op...
4
0
[]
2
24-game
Python3 solution with eval()
python3-solution-with-eval-by-todor91-k3oi
Here I just simulate all permutations of numbers and operators and use the builtin eval() function to get the result. There are 6 different cases for parenthese
todor91
NORMAL
2020-05-22T11:37:56.052243+00:00
2020-05-22T12:07:20.292383+00:00
210
false
Here I just simulate all permutations of numbers and operators and use the builtin eval() function to get the result. There are 6 different cases for parentheses and I iterate through all of them.\n\n```\n def judgePoint24(self, nums: List[int]) -> bool:\n\n @lru_cache(None)\n def solve(a, b, c, d):\n ...
4
0
[]
0
24-game
Java bringing new meaning to brute force
java-bringing-new-meaning-to-brute-force-c97f
\nThis is just an Intellij inline-method refactoring of this other ugly solution: https://leetcode.com/problems/24-game/discuss/584767/Java-no-control-flow-(no-
glxxyz
NORMAL
2020-04-18T05:57:49.705862+00:00
2020-04-18T06:03:52.959694+00:00
593
false
\nThis is just an Intellij inline-method refactoring of this other ugly solution: https://leetcode.com/problems/24-game/discuss/584767/Java-no-control-flow-(no-if-for-while-etc.)-beats-100-time-100-space\n\nFor some reason it\'s much slower and uses much more memory than the version with method calls. Maybe someone who...
4
0
['Java']
3
24-game
Python, Time: O(1)[100.0%], Space: O(1)[100.0%], precalculation, cheat solution
python-time-o11000-space-o11000-precalcu-xu6p
\nBy just list all cases, it can run very fase!!!\nThis kinds of precalculate cheat are common skill to let program even more faster.\nHowever, it still need a
chumicat
NORMAL
2019-11-29T17:50:54.378734+00:00
2019-11-30T07:32:27.285059+00:00
1,205
false
\nBy just list all cases, it can run very fase!!!\nThis kinds of precalculate cheat are common skill to let program even more faster.\nHowever, it still need a right solution to generate all cases.\n(Markdown didn\'t work in result which will let this arcitle a littlle bit messy :p)\n\n=================================...
4
3
['Python', 'Python3']
0
24-game
Python, Functional style
python-functional-style-by-awice-qnu1
We write a function apply that takes two sets of possibilities for A and B and returns all possible results operator(A, B) or operator(B, A) for all possible op
awice
NORMAL
2017-09-17T05:35:10.366000+00:00
2017-09-17T05:35:10.366000+00:00
1,344
false
We write a function `apply` that takes two sets of possibilities for A and B and returns all possible results `operator(A, B)` or `operator(B, A)` for all possible operators.\n\nIgnoring reflection, there are only two ways we can apply the operators: (AB)(CD) or ((AB)C)D. When C and D are ordered, this becomes three w...
4
1
[]
2
24-game
24 Game DFS
24-game-dfs-by-tanmaybhujade-todc
\n\n# Code\n\nclass Solution {\n private final char[] ops = {\'+\', \'-\', \'*\', \'/\'};\n\n public boolean judgePoint24(int[] cards) {\n List<Dou
tanmaybhujade
NORMAL
2024-03-29T17:15:08.897839+00:00
2024-03-29T17:15:08.897861+00:00
815
false
\n\n# Code\n```\nclass Solution {\n private final char[] ops = {\'+\', \'-\', \'*\', \'/\'};\n\n public boolean judgePoint24(int[] cards) {\n List<Double> nums = new ArrayList<>();\n for (int num : cards) {\n nums.add((double) num);\n }\n return dfs(nums);\n }\n\n priv...
3
0
['Java']
0
24-game
[C++] Simple C++ Code
c-simple-c-code-by-prosenjitkundu760-afmz
\n# If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\n d
_pros_
NORMAL
2022-08-19T06:41:49.107854+00:00
2022-08-19T06:42:35.954633+00:00
493
false
\n# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\n double error=0.001;\n vector<double> opnxy(double x, double y)\n {\n vector<double> ans;\n if(x > error)\n ans.push_back(x/...
3
0
['Backtracking', 'C']
0
24-game
Easy C++ Solution
easy-c-solution-by-shreya1393-xq64
\nclass Solution {\npublic:\n bool helper(vector<float> cards) {\n int n = cards.size();\n // cout << "size is " << n << endl;\n if (n ==
shreya1393
NORMAL
2021-12-31T20:36:47.579712+00:00
2021-12-31T20:36:47.579742+00:00
568
false
```\nclass Solution {\npublic:\n bool helper(vector<float> cards) {\n int n = cards.size();\n // cout << "size is " << n << endl;\n if (n == 1) {\n //cout << cards[0] << endl;\n if (abs(cards[0]-24) < 0.001) {\n return true;\n }\n return ...
3
0
['Backtracking']
3
24-game
Python beats 99% - hopefully clear code and explanation
python-beats-99-hopefully-clear-code-and-k3ql
\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n \n self.allcombos = []\n \n # need all combinations of ca
thess24
NORMAL
2021-12-27T04:59:47.933096+00:00
2021-12-27T05:09:40.209004+00:00
802
false
```\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n \n self.allcombos = []\n \n # need all combinations of cards\n def permute(arr,remcards):\n if len(arr)==4:\n self.allcombos.append(arr[:])\n return\n ...
3
0
['Python']
1
24-game
Python | Backtracking | Also generates the solution expressions
python-backtracking-also-generates-the-s-49df
I was asked this question in a technical interview, with a slight variation--instead of a boolean, they wanted me to return a list of the expressions that would
GracelessGhost
NORMAL
2021-10-22T06:34:58.223809+00:00
2021-10-22T06:36:15.450535+00:00
735
false
I was asked this question in a technical interview, with a slight variation--instead of a boolean, they wanted me to return a list of the expressions that would reach the target number. This was my solution. The basic idea is:\n\n1. Since every operation is binary, you can partition the list of nums into two entities.\...
3
0
['Backtracking', 'Python']
1
24-game
Simple, clean python (beats 98%)
simple-clean-python-beats-98-by-bingoban-sg8o
\timport itertools\n\tclass Solution:\n\t\tdef judgePoint24(self, cards: List[int]) -> bool:\n\n\t\t\t@lru_cache(None)\n\t\t\tdef helper(nums):\n\t\t\t\tif(len(
bingobango3846
NORMAL
2021-08-16T21:43:11.130372+00:00
2021-08-16T21:43:11.130406+00:00
438
false
\timport itertools\n\tclass Solution:\n\t\tdef judgePoint24(self, cards: List[int]) -> bool:\n\n\t\t\t@lru_cache(None)\n\t\t\tdef helper(nums):\n\t\t\t\tif(len(nums) == 1):\n\t\t\t\t\treturn nums\n\t\t\t\t\t\n\t\t\t\tpossible = set()\n\t\t\t\tfor i in range(1, len(nums)):\n\t\t\t\t\tleft = helper(nums[0:i])\n\t\t\t\t\t...
3
1
[]
1
24-game
C++
c-by-wangjiacode-iytm
C++\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& nums) {\n vector<double> a(nums.begin(), nums.end());\n return dfs(a);\n }\n
wangjiacode
NORMAL
2021-03-11T07:41:35.505543+00:00
2021-03-11T07:41:35.505575+00:00
315
false
```C++\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& nums) {\n vector<double> a(nums.begin(), nums.end());\n return dfs(a);\n }\n vector<double> get(int i, int j, double c, vector<double>& nums) {\n vector<double> res;\n for (int k = 0; k < nums.size(); k ++) {\n ...
3
0
[]
1
24-game
[JAVA] Simple DFS solution
java-simple-dfs-solution-by-final_destin-vr5l
``` \npublic boolean judgePoint24(int[] nums) {\n ArrayList list = new ArrayList<>();\n for(int i: nums){\n list.add((double)i);\n
final_destiny
NORMAL
2020-12-28T03:38:27.552550+00:00
2020-12-28T03:38:27.552582+00:00
326
false
``` \npublic boolean judgePoint24(int[] nums) {\n ArrayList<Double> list = new ArrayList<>();\n for(int i: nums){\n list.add((double)i);\n }\n \n return dfs(list);\n \n }\n \n boolean dfs(List<Double> list) {\n if (list.size() == 0) return false;\n ...
3
0
[]
0
24-game
C++ clean and fast
c-clean-and-fast-by-yytlc-igjp
\nclass Solution {\nvector<double> v;\nbool flag = false;\n\nvoid dfs(int n){\n \n if(n == 1){\n if(abs(v[0] - 24) <= 0.0000001){\n flag
yytlc
NORMAL
2020-05-07T08:23:15.562646+00:00
2020-05-07T08:23:15.562683+00:00
268
false
```\nclass Solution {\nvector<double> v;\nbool flag = false;\n\nvoid dfs(int n){\n \n if(n == 1){\n if(abs(v[0] - 24) <= 0.0000001){\n flag = true;\n }\n return;\n }\n \n for(int i = 0; i < n; ++i){\n for(int j = i + 1; j < n; ++j){\n double a = v[i];\n ...
3
0
[]
0
24-game
Clean C++ solution using Rational class
clean-c-solution-using-rational-class-by-6tpy
c++\nclass Rational {\npublic:\n Rational() {}\n Rational(int num) : Rational(num, 1) {}\n \n bool is(int target) const {\n if (denom == 0 ||
kibeom
NORMAL
2018-12-04T00:54:06.822993+00:00
2018-12-04T00:54:06.823049+00:00
334
false
```c++\nclass Rational {\npublic:\n Rational() {}\n Rational(int num) : Rational(num, 1) {}\n \n bool is(int target) const {\n if (denom == 0 || num % denom != 0)\n return false;\n return num / denom == target;\n }\n\n friend Rational operator+(const Rational &lhs, const Ratio...
3
0
[]
1
24-game
AC C++ solution beats 100%, easy to understand
ac-c-solution-beats-100-easy-to-understa-d2fq
AC C++ solution beats 100%, easy to understand\n\n bool game(vector<double> & nums,int n)\n {\n if(n==1)\n {\n if(fabs(nums[0]-24)<1
zyy344858
NORMAL
2018-08-15T01:25:50.236370+00:00
2018-10-25T16:03:28.547124+00:00
512
false
AC C++ solution beats 100%, easy to understand\n```\n bool game(vector<double> & nums,int n)\n {\n if(n==1)\n {\n if(fabs(nums[0]-24)<1e-6)\n return true;\n else \n return false;\n \n \n \n }\n \n ...
3
0
[]
0
24-game
Very Short and Clean Solution
very-short-and-clean-solution-by-charnav-4nbb
null
charnavoki
NORMAL
2025-02-27T13:07:30.751697+00:00
2025-02-27T13:07:30.751697+00:00
146
false
```javascript [] const ops = [(a, b) => a + b, (a, b) => a - b, (a, b) => b - a, (a, b) => a * b, (a, b) => a / b, (a, b) => b / a]; const judgePoint24 = (nums, [a, b, c, d] = nums) => { switch (nums.length) { case 4: return [[a, b, c, d], [a, c, b, d], [a, d, c, b], [b, c, a, d], [b, d, a, c], [c, d, a, b]...
2
0
['JavaScript']
0
24-game
Rust || 1ms || beats 100%
rust-1ms-beats-100-by-user7454af-wt36
Complexity\n- Time complexity: O(2^n) = O(2^4)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(2^n) = O(2^4)\n Add your space complexity he
user7454af
NORMAL
2024-06-14T22:47:08.396518+00:00
2024-06-14T22:47:08.396554+00:00
129
false
# Complexity\n- Time complexity: $$O(2^n) = O(2^4)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(2^n) = O(2^4)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimpl Solution {\n pub fn judge_point24(mut cards: Vec<i32>) -> bool {\n let cards = car...
2
0
['Rust']
0
24-game
Solution
solution-by-deleted_user-n2qe
C++ []\nclass Solution {\npublic:\n std::vector<double> available_nums;\n bool bt() {\n if (available_nums.size() == 1) {\n auto v = ava
deleted_user
NORMAL
2023-04-18T12:42:02.262196+00:00
2023-04-18T12:53:54.683859+00:00
1,116
false
```C++ []\nclass Solution {\npublic:\n std::vector<double> available_nums;\n bool bt() {\n if (available_nums.size() == 1) {\n auto v = available_nums.back();\n return abs(v - 24.) < .01;\n }\n for (size_t i = 0; i < available_nums.size(); ++i) {\n for (size_t...
2
0
['C++', 'Java', 'Python3']
1
24-game
Easy C++ Solution | Trial & Error Method
easy-c-solution-trial-error-method-by-ra-633k
\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& cards) {\n return solve(vector<double>(cards.begin(),cards.end()));\n }\n vector<d
rac101ran
NORMAL
2022-10-07T13:06:24.725529+00:00
2022-10-07T13:06:24.725573+00:00
955
false
```\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& cards) {\n return solve(vector<double>(cards.begin(),cards.end()));\n }\n vector<double> solveType(double x,double y) {\n return {x + y,x - y,x * y,y - x, x / y , y / x};\n }\n bool solve(vector<double> a) {\n if(a.s...
2
0
['Math', 'C']
0
24-game
easy c
easy-c-by-balsi2oo1-sa7p
\nbool judgePoint24(int* nums, int numsSize){\n double a=nums[0],b=nums[1],c=nums[2],d=nums[3];\n return judgePoint24_4(a,b,c,d);\n}\nint judgePoint24_1(dou
balsi2OO1
NORMAL
2022-04-25T08:19:26.046357+00:00
2022-04-25T08:19:26.046406+00:00
200
false
```\nbool judgePoint24(int* nums, int numsSize){\n double a=nums[0],b=nums[1],c=nums[2],d=nums[3];\n return judgePoint24_4(a,b,c,d);\n}\nint judgePoint24_1(double a){\n return a-24>-1e-6 && a-24<1e-6;\n}\nint judgePoint24_2(double a,double b){\n return (judgePoint24_1(a+b)||\n judgePoint24_1(a*b)||...
2
0
['C']
1
24-game
[Python3] dp
python3-dp-by-ye15-1hdq
\n\nfrom fractions import Fraction\n\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n \n @cache\n def fn(*args): \
ye15
NORMAL
2021-12-02T22:30:56.791842+00:00
2021-12-02T22:33:30.577423+00:00
388
false
\n```\nfrom fractions import Fraction\n\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n \n @cache\n def fn(*args): \n """Return True if arguments can be combined into 24."""\n if len(args) == 1: return args[0] == 24\n for x, y, *rem in perm...
2
0
['Python3']
0
24-game
Python3 - clean code
python3-clean-code-by-karrenbelt-ie7d
python\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n # I use fractions because of floating point arithmetic\n # size i
karrenbelt
NORMAL
2021-08-12T09:25:34.599957+00:00
2021-08-12T09:26:54.967584+00:00
416
false
```python\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n # I use fractions because of floating point arithmetic\n # size is 24 [nums] x 64 [operators] x 2 [precedence]\n from operator import add, sub, mul\n from fractions import Fraction\n from itertools imp...
2
1
[]
1
24-game
Python Backtracking
python-backtracking-by-mcmar-0eaf
Inspired by https://leetcode.com/problems/24-game/discuss/1062871/Python-dfs\nPlease check out and like his post.\nI just changed the ops handling to my preferr
mcmar
NORMAL
2021-06-23T02:50:40.877017+00:00
2021-06-23T02:50:40.877053+00:00
559
false
Inspired by https://leetcode.com/problems/24-game/discuss/1062871/Python-dfs\nPlease check out and like his post.\nI just changed the ops handling to my preferred method with fewer special cases.\nI was previously doing backtracking by deleting and inserting indexes back into the cards array. I like this more because i...
2
2
['Backtracking', 'Python']
1
24-game
Python solution
python-solution-by-dmyma-si2q
The main idea is to shorten the array by one operation in each iteration. Thus, we take first element from cards a and second from cards b, perform operation an
dmyma
NORMAL
2021-05-27T02:42:59.327665+00:00
2021-05-27T02:42:59.327702+00:00
258
false
The main idea is to shorten the array by one operation in each iteration. Thus, we take first element from cards `a` and second from cards `b`, perform operation and merge it with what is left.\n\n```\nclass Solution:\n def judgePoint24(self, cards: List[int]) -> bool:\n if len(cards) == 1: return abs(cards[0...
2
0
[]
2
24-game
Python Solution For Fun
python-solution-for-fun-by-mbylzy-digo
\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n ans=[[1, 1, 1, 8], [1, 1, 2, 6], [1, 1, 2, 7], [1, 1, 2, 8], [1, 1, 2, 9], [1,
mbylzy
NORMAL
2021-02-17T04:21:24.242321+00:00
2021-02-17T04:21:24.242375+00:00
247
false
```\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n ans=[[1, 1, 1, 8], [1, 1, 2, 6], [1, 1, 2, 7], [1, 1, 2, 8], [1, 1, 2, 9], [1, 1, 3, 4], [1, 1, 3, 5], [1, 1, 3, 6], [1, 1, 3, 7], [1, 1, 3, 8], [1, 1, 3, 9], [1, 1, 4, 4], [1, 1, 4, 5], [1, 1, 4, 6], [1, 1, 4, 7], [1, 1, 4, 8], [1, 1, ...
2
6
[]
1
24-game
12ms C++ solution using DFS
12ms-c-solution-using-dfs-by-ziplin-aa2p
\n vector<double> util(vector<double> a,vector<double> b){\n vector<double> r;\n for(int i=0;i<a.size();i++){\n for(int j=0;j<b.size
ziplin
NORMAL
2020-09-27T11:58:01.285912+00:00
2020-09-27T11:58:53.992971+00:00
387
false
```\n vector<double> util(vector<double> a,vector<double> b){\n vector<double> r;\n for(int i=0;i<a.size();i++){\n for(int j=0;j<b.size();j++){\n r.push_back(a[i]+b[j]);\n r.push_back(a[i]*b[j]);\n r.push_back(a[i]/b[j]);\n r.push_b...
2
0
['Depth-First Search', 'C']
0
24-game
Fast and Intuitive Java solution 2ms beats 86%
fast-and-intuitive-java-solution-2ms-bea-cpyv
The algorithm is simple, pick 2 values at a time, and try all possible combination of operators on it, and create a new array that you pass to the next recusive
yjin02
NORMAL
2020-09-20T01:22:01.104664+00:00
2020-09-20T01:22:25.981365+00:00
214
false
The algorithm is simple, pick 2 values at a time, and try all possible combination of operators on it, and create a new array that you pass to the next recusive call.\nif the array length is 1, we check to see if the number if 24\n\n```\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n double[]...
2
0
[]
0
24-game
Self Explaintory
self-explaintory-by-anmolgera-yfho
\n\n\nclass Solution {\npublic:\n bool judgePoint24(vector& nums) {\n \n sort(nums.begin(), nums.end());\n do {\n if (valid(nu
anmolgera
NORMAL
2020-08-03T02:18:51.457007+00:00
2020-08-03T02:18:51.457070+00:00
173
false
\n\n\nclass Solution {\npublic:\n bool judgePoint24(vector<int>& nums) {\n \n sort(nums.begin(), nums.end());\n do {\n if (valid(nums)) return true;\n } while(next_permutation(nums.begin(), nums.end()));\n return false;\n }\n\n bool valid(vector<int>& nums) {\n ...
2
0
[]
2
24-game
Java arrays only - no lists, faster than 85%
java-arrays-only-no-lists-faster-than-85-qcas
```\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n double[] d = new double[nums.length];\n for (int i=0; i 23.9999999999999 &&
likhvarev
NORMAL
2020-05-25T06:58:19.574393+00:00
2020-05-25T06:58:19.574440+00:00
217
false
```\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n double[] d = new double[nums.length];\n for (int i=0; i<nums.length; i++) {\n d[i] = nums[i];\n }\n return check(d);\n }\n \n private boolean check(double[] nums) {\n if (nums.length == 1) {\n ...
2
0
[]
1
24-game
Java no control flow (no if, for, while, etc.), beats 100% time, 100% space
java-no-control-flow-no-if-for-while-etc-xrmd
With only 4 inputs this problem can be solved with basically only booleans and math operations.\n\nThis code doesn\'t make any assumptions about the inputs bein
glxxyz
NORMAL
2020-04-18T05:52:56.525952+00:00
2020-04-18T19:12:33.949370+00:00
650
false
With only 4 inputs this problem can be solved with basically only booleans and math operations.\n\nThis code doesn\'t make any assumptions about the inputs being in the range 1-9, they could be any integers and it would still work fine- the solutions that encode all possible answers only work with 1-9 inputs.\n\nThis s...
2
2
['Java']
1
24-game
Easy to understand recursive JAVA solution
easy-to-understand-recursive-java-soluti-oo05
\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n List<Double> list = new ArrayList<>();\n for (int num : nums) list.add((double
legendaryengineer
NORMAL
2020-03-31T21:09:55.470105+00:00
2020-03-31T21:09:55.470139+00:00
259
false
```\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n List<Double> list = new ArrayList<>();\n for (int num : nums) list.add((double) num);\n return can(list);\n }\n \n private boolean can(List<Double> list) {\n if (list.size() == 1) return (Math.abs(list.get(0) - 2...
2
0
[]
2
24-game
Javascript and Python
javascript-and-python-by-andyoung-6cye
Idea\n1. recursively try every pair of nums[i] and nums[j], with rest numbers from nums\n\nJavascript\njs\nvar judgePoint24 = function(nums) {\n if (nums.len
andyoung
NORMAL
2020-03-08T04:15:24.385612+00:00
2020-03-08T19:33:30.388163+00:00
451
false
**Idea**\n1. recursively try every pair of `nums[i]` and `nums[j]`, with rest numbers from `nums`\n\n**Javascript**\n```js\nvar judgePoint24 = function(nums) {\n if (nums.length == 1) {\n return Math.abs(nums[0] - 24) < 0.01;\n }\n\n let ans = false;\n for (let i = 0; i < nums.length; ++i) {\n ...
2
1
['Python', 'JavaScript']
1
24-game
Swift solution
swift-solution-by-zzhenia-9vs0
The code below is a simple implementation of the solution provided to the problem with the following stats:\n\n> Runtime: 220 ms, faster than 10.53% of Swift on
zzhenia
NORMAL
2020-02-24T17:37:35.960005+00:00
2020-02-24T17:37:35.960049+00:00
224
false
The code below is a simple implementation of the solution provided to the problem with the following stats:\n\n> Runtime: 220 ms, faster than 10.53% of Swift online submissions for 24 Game.\nMemory Usage: 21.1 MB, less than 100.00% of Swift online submissions for 24 Game.\n\nI wonder how could I make it faster and what...
2
0
['Swift']
1
24-game
Python straightforward recursive solution
python-straightforward-recursive-solutio-snf8
\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n if len(nums) == 1:\n return abs(nums[0] - 24) < 10**-3\n for
tsuai
NORMAL
2019-12-02T08:21:15.891063+00:00
2019-12-02T08:21:15.891101+00:00
315
false
```\nclass Solution:\n def judgePoint24(self, nums: List[int]) -> bool:\n if len(nums) == 1:\n return abs(nums[0] - 24) < 10**-3\n for i in range(len(nums)):\n for j in range(i + 1, len(nums)):\n add = nums[i] + nums[j]\n minus = nums[i] - nums[j]\n ...
2
0
[]
0
24-game
Python beats 95%
python-beats-95-by-etherwei-ishc
Python seems to have float precision problem so we need to manually check the returned results.\nUsing set to filter out duplicate numbers.\n\n def judgePoin
etherwei
NORMAL
2019-07-12T04:50:20.369996+00:00
2019-07-12T04:50:20.370029+00:00
465
false
Python seems to have float precision problem so we need to manually check the returned results.\nUsing set to filter out duplicate numbers.\n```\n def judgePoint24(self, nums):\n """\n :type nums: List[int]\n :rtype: bool\n """\n\n def helper(start, end, arr):\n if start...
2
0
[]
0
24-game
Simple Java solution beats 100%
simple-java-solution-beats-100-by-karayv-n0mc
\n public boolean judgePoint24(int[] nums) {\n double[] dbls = new double[nums.length];\n for (int i = 0; i < nums.length; i++) dbls[i] = (doub
karayv
NORMAL
2019-03-31T07:22:53.457037+00:00
2019-03-31T07:22:53.457104+00:00
309
false
```\n public boolean judgePoint24(int[] nums) {\n double[] dbls = new double[nums.length];\n for (int i = 0; i < nums.length; i++) dbls[i] = (double) nums[i];\n return solve(dbls);\n }\n\n private boolean solve(double[] dbls) {\n if (dbls.length == 1) {\n return Math.abs(...
2
0
[]
0
24-game
Java recursive easy to read
java-recursive-easy-to-read-by-lootshen-ayj8
\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n double[] doubles = new double[4];\n for (int i = 0; i < 4; i++) {\n
lootshen
NORMAL
2019-03-26T18:40:12.759126+00:00
2019-03-26T18:40:12.759192+00:00
239
false
```\nclass Solution {\n public boolean judgePoint24(int[] nums) {\n double[] doubles = new double[4];\n for (int i = 0; i < 4; i++) {\n doubles[i] = nums[i] / 1.0;\n }\n return dfs(doubles);\n }\n\n public boolean dfs(double[] nums) {\n int n = nums.length;\n ...
2
1
[]
0